Click here to Skip to main content
Licence CPOL
First Posted 17 Nov 2008
Views 8,945
Bookmarked 14 times

Getting version from MSI without installing it

By | 17 Nov 2008 | Article
To get the version number from an MSI file without installing it.

Introduction

This article is used to fetch the version number from an MSI without installing the MSI.

Background

In C#, to access this, we need to have a reference to msi.dll which exists in the system32 folder of the system.

Using the Code

To access the version number or other product related stuff, we need to have the DLL reference in Visual Studio .NET.

DLL name: msi.dll (which 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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Haribhk



Unknown

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Question.msu ? PinmemberDokMuffin5:43 18 Nov '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 17 Nov 2008
Article Copyright 2008 by Haribhk
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid