Click here to Skip to main content
6,292,811 members and growing! (11,288 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » General     Beginner License: The Code Project Open License (CPOL)

Getting Version from MSI without Installing It

By Haribhk

To get the version number from msi without installing the msi
C#, WindowsVS.NET2003, VS2005, Architect
Posted:17 Nov 2008
Views:3,181
Bookmarked:11 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
4 votes for this article.
Popularity: 1.63 Rating: 2.71 out of 5
1 vote, 25.0%
1

2
2 votes, 50.0%
3

4
1 vote, 25.0%
5

Introduction

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

Background

In C# to access this we need to have reference to msi.dll which is exists in 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 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

License

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

About the Author

Haribhk


Member

Location: United States United States

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
General.msu ? PinmemberDokMuffin6:43 18 Nov '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 17 Nov 2008
Editor: Sean Ewington
Copyright 2008 by Haribhk
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project