Example #1
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            // open file
            //   MSI.Package mpkg = new MSI.Package(msifile);
            // list tables and records

            // WindowsInstaller.View view = database.OpenView("SELECT * FROM _table_name);
            MSI.Database mdb = new MSI.Database(msifile, MSI.Database.OpenMode.ReadOnly);
            mdb.Export("registry", @"C:\Program Files\Educational Assessments Corporation\EACZipInstallerMaker\CurrentMsi\", "RegExport.txt");
            MSI.View mdbv = mdb.OpenView("SELECT * FROM Registry");
            mdbv.Execute();
            MSI.Record rmdb  = mdbv.Fetch();
            int        total = rmdb.FieldCount;

            while (rmdb != null)
            {
                for (int i = 1; i <= total; i++)
                {
                    if (rmdb.GetString(i) != null)
                    {
                        string temp = rmdb.GetString(i);
                        //  temp = temp.Replace(txtFind.Text, txtReplace.Text);
                        // record.set_StringData(i, temp);
                        // view.Modify(MsiViewModify.msiViewModifyReplace, record);
                        tbMemo.AppendText(temp);
                    }
                }
                rmdb = mdbv.Fetch();
            }
            // edit record
            // save changes and file
        }
Example #2
0
 public void Commit(IzFree.Project project, string rootDirectory,
                    string rootFeature)
 {
     CommitFiles(project);
     MSI.Database db = project.Database;
     CommitDirectories(db, rootDirectory);
     CommitMedia(db);
     CommitComponents(db);
     CommitFeatures(db, rootFeature);
     CommitFeatureComponents(db);
 }
Example #3
0
        private int ScrapeFileCounter(MSI.Database db)
        {
            int count = 0;

            using (MSI.View view =
                       Application.ExecView(db, "SELECT `File` FROM `File`"))
            {
                for (MSI.Record rec = view.Fetch(); rec != null; rec = view.Fetch())
                {
                    count++;
                    rec.Dispose();
                }
            }
            return(count);
        }
Example #4
0
 private void CommitFeatureComponents(MSI.Database db)
 {
     using (MSI.View view = db.OpenView("INSERT INTO " +
                                        "`FeatureComponents`(`Feature_`,`Component_`) " +
                                        "VALUES (?,?)"))
     {
         for (int i = 0; i < m_components.Count; i++)
         {
             string name = (m_components[i] as Component).Name;
             using (MSI.Record rec = new MSI.Record(2))
             {
                 rec.SetString(1, name);
                 rec.SetString(2, name);
                 view.Execute(rec);
             }
         }
         view.Close();
     }
 }
Example #5
0
        private void CommitFeatures(MSI.Database db, string root)
        {
            int display = 0;

            using (MSI.View view = Application.ExecView(db,
                                                        "SELECT `Display` FROM `Feature` ORDER BY `Display`"))
            {
                for (MSI.Record rec = view.Fetch(); rec != null; rec = view.Fetch())
                {
                    if (!rec.IsNull(1))
                    {
                        display = Math.Max(rec.GetInteger(1) / 2, display);
                    }
                    rec.Dispose();
                }
                view.Close();
            }
            display = (0 == display) ? 100 : display + 1;

            using (MSI.View view = db.OpenView("INSERT INTO `Feature`(" +
                                               "`Feature`,`Feature_Parent`,`Title`,`Description`," +
                                               "`Display`,`Level`,`Directory_`,`Attributes`) " +
                                               "VALUES (?,?,?,?,?,?,?,0)"))
            {
                for (int i = 0; i < m_components.Count; i++)
                {
                    Component component = m_components[i] as Component;
                    using (MSI.Record rec = new MSI.Record(7))
                    {
                        rec.SetString(1, component.Name);
                        rec.SetString(2, root);
                        rec.SetString(3, component.Name);
                        rec.SetString(4, component.Name);
                        rec.SetInteger(5, 2 * (i + display));
                        rec.SetInteger(6, 1);
                        rec.SetString(7, "");
                        view.Execute(rec);
                    }
                }
                view.Close();
            }
        }
Example #6
0
 private void CommitComponents(MSI.Database db)
 {
     using (MSI.View view = db.OpenView("INSERT INTO `Component`(" +
                                        "`Component`,`ComponentId`,`Directory_`,`Attributes`," +
                                        "`Condition`,`KeyPath`) VALUES (?,?,?,0,'','')"))
     {
         for (int i = 0; i < m_components.Count; i++)
         {
             Component component = m_components[i] as Component;
             using (MSI.Record rec = new MSI.Record(3))
             {
                 rec.SetString(1, component.Name);
                 rec.SetString(2, Application.NewGuid());
                 rec.SetString(3, component.Directory.Name);
                 view.Execute(rec);
             }
         }
         view.Close();
     }
 }
Example #7
0
        private void CommitMedia(MSI.Database db)
        {
            bool insert;

            using (MSI.View view = Application.ExecView(db,
                                                        "SELECT * FROM `Media`"))
                using (MSI.Record rec = view.Fetch())
                {
                    insert = (null == rec);
                    view.Close();
                }
            if (insert)
            {
                using (MSI.View view = Application.ExecView(db,
                                                            "INSERT INTO `Media`(`DiskId`,`LastSequence`," +
                                                            "`DiskPrompt`,`Cabinet`,`VolumeLabel`,`Source`) " +
                                                            "VALUES (1,1,'','','','')"))
                {
                    view.Close();
                }
            }
        }
Example #8
0
        private void CommitFiles(IzFree.Project project)
        {
            MSI.Database db          = project.Database;
            int          fileCounter = FileCounter(project);

            using (MSI.View view = db.OpenView("INSERT INTO `File`(" +
                                               "`File`,`Component_`,`FileName`,`FileSize`,`Version`," +
                                               "`Language`,`Attributes`,`Sequence`) " +
                                               "VALUES (?,?,?,?,?,?,0,1)"))
            {
                for (int i = 0; i < m_files.Count; i++)
                {
                    File file = m_files[i] as File;
                    using (MSI.Record rec = new MSI.Record(6))
                    {
                        rec.SetString(1, DatabaseKey(file.Name) + "_f" +
                                      (fileCounter + i).ToString());
                        rec.SetString(2, file.Component.Name);
                        rec.SetString(3, (file.ShortName.Length > 0) ?
                                      file.ShortName + "|" + file.Name : file.Name);
                        rec.SetInteger(4, (int)file.Size);
                        rec.SetString(5, file.Version);
                        if (file.Version != "")
                        {
                            rec.SetInteger(6, 0);
                        }
                        else
                        {
                            rec.SetString(6, "");
                        }
                        view.Execute(rec);
                    }
                }
                view.Close();
            }

            project.SetIzProperty("FileCounter",
                                  (fileCounter + m_files.Count).ToString());
        }
Example #9
0
 private void CommitDirectories(MSI.Database db, string root)
 {
     using (MSI.View view = db.OpenView("INSERT INTO `Directory`(" +
                                        "`Directory`,`Directory_Parent`,`DefaultDir`) " +
                                        " VALUES (?,?,?)"))
     {
         for (int i = 0; i < m_directories.Count; i++)
         {
             Directory dir = m_directories[i] as Directory;
             if (dir.Name != "APPDIR")
             {
                 using (MSI.Record rec = new MSI.Record(3))
                 {
                     rec.SetString(1, dir.Name);
                     rec.SetString(2, dir.Parent);
                     rec.SetString(3, dir.DefaultDirectory);
                     view.Execute(rec);
                 }
             }
         }
         view.Close();
     }
 }