Click here to Skip to main content
5,788,212 members and growing! (19,548 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, Visual Studio, Architect

Posted: 17 Nov 2008
Updated: 17 Nov 2008
Views: 1,366
Bookmarked: 11 times
Note: This is an unedited reader contribution
Announcements
Loading...



Search    
Advanced Search
Sitemap
3 votes for this Article.
Popularity: 1.11 Rating: 2.33 out of 5
1 vote, 33.3%
1
0 votes, 0.0%
2
2 votes, 66.7%
3
0 votes, 0.0%
4
0 votes, 0.0%
5
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

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



Location: United States United States

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
General.msu ?memberDokMuffin6: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
Web15 | Advertise on the Code Project