|
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionThis ariticle is used to fetch the version number from an MSI without installing the MSI. BackgroundIn C# to access this we need to have reference to msi.dll which is exists in system32 folder of the system Using the CodeTo access the version number or other product related stuff we need to have the DLL reference in our visual studio dotnet. DLL name: msi.dll (which is exists in system32)
Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer");
WindowsInstaller.Installer installer = (WindowsInstaller.Installer)
Activator.CreateInstance(type);
WindowsInstaller.Database db = installer.OpenDatabase(
@"D:\SEDC\Services\MyCodeSetup.msi", 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();// here you will get the version number
|
||||||||||||||||||||||||||||||||||||||||