Esempio n. 1
0
 public static void TR(Database db, UInt32 result)
 {
     if (result != 0)
     {
         Record error = LastErrorRecord;
         if ((error != null) && (error.FieldCount > 0))
         {
             System.Diagnostics.Debug.WriteLine(
                 String.Format("Windows Installer Error {0}:\n{1}",
                               error.GetInteger(1), ErrorText(db, error)));
             System.Diagnostics.Debug.WriteLine(
                 (new System.Diagnostics.StackTrace()).ToString());
         }
         throw new Win32Exception((int)result);
     }
 }
Esempio n. 2
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();
            }
        }