I need to get version of msp-files. For msi-files, I use next code:
public static string GetMSIVersion(string MSIPath)
{
try
{
Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer");
WindowsInstaller.Installer installer = (WindowsInstaller.Installer)
Activator.CreateInstance(type);
WindowsInstaller.Database db = installer.OpenDatabase(MSIPath, 0);
WindowsInstaller.View dv = db.OpenView("SELECT `Value` FROM `Property` WHERE `Property`='ProductVersion'");
WindowsInstaller.Record record = null;
dv.Execute(record);
record = dv.Fetch();
string str = record.get_StringData(1).ToString();
return str;
}
catch (Exception ex)
{
return "";
}
}
But for msp it's not working. Any ideas?
You need to specify MSP database type when OpenDatabase, replace 0 with
MsiOpenDatabaseMode.msiOpenDatabaseModePatchFile
(32)Then you can receive all tables inside the msp:
It should contain patch tables listed there. MSP file may not contain
Property
table inside .