コード例 #1
0
        public static MsiInfo GetMsiInfo(string filename)
        {
            // Create an Installer instance
            Type classType = Type.GetTypeFromProgID("WindowsInstaller.Installer");
            var installer = Activator.CreateInstance(classType) as Installer;

            if (installer == null)
                throw new Exception("Unable to create instance of COM Object WindowsInstaller.Installer");

            // Open the msi file for reading
            // 0 - Read, 1 - Read/Write
            Database database = installer.OpenDatabase(filename, 0);

            var info = new MsiInfo
                           {
                               Manufacturer = GetProperty(database, "Manufacturer"),
                               ProductName = GetProperty(database, "ProductName"),
                               ProductCode = GetProperty(database, "ProductCode"),
                               ProductVersion = GetProperty(database, "ProductVersion"),
                           };

            Marshal.FinalReleaseComObject(database);

            return info;
        }
コード例 #2
0
        public static MsiInfo GetMsiInfo(string filename)
        {
            // Create an Installer instance
            Type classType = Type.GetTypeFromProgID("WindowsInstaller.Installer");
            var  installer = Activator.CreateInstance(classType) as Installer;

            if (installer == null)
            {
                throw new Exception("Unable to create instance of COM Object WindowsInstaller.Installer");
            }

            // Open the msi file for reading
            // 0 - Read, 1 - Read/Write
            Database database = installer.OpenDatabase(filename, 0);

            var info = new MsiInfo
            {
                Manufacturer   = GetProperty(database, "Manufacturer"),
                ProductName    = GetProperty(database, "ProductName"),
                ProductCode    = GetProperty(database, "ProductCode"),
                ProductVersion = GetProperty(database, "ProductVersion"),
            };

            Marshal.FinalReleaseComObject(database);

            return(info);
        }