• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4729
  • Last Modified:

Programatically reading .msi build version

I'm creating a web site from which to download msi-files, and I want to "query" the .msi files for version information. (Note that I'm after the install kit version, not the version of files inside the install kit)

Specifically I want to be able to query the site from an application to check if there is a newer version of an install kit available for download, and I want a web page to display the version number of an msi-file available on the site.

I gave wrapping MsiGetFileVersion in msi.dll a quick try, but it doesn't give me anything. Might be that the below method is not the one I want.

Any ideas?



[DllImport("msi.dll", CharSet = CharSet.Unicode)]
extern static public uint MsiGetFileVersion(string path, StringBuilder version,
			ref uint versionSize, StringBuilder language, ref uint languageSize);

Open in new window

0
alaran
Asked:
alaran
  • 2
1 Solution
 
alaranAuthor Commented:
Not to worry, I got it.

Here's some sample code it anyone's interested.

WindowsInstaller.Installer inst = (Installer) Activator.CreateInstance(Type.GetTypeFromProgID("WindowsInstaller.Installer"));
 
Database db = inst.OpenDatabase(Server.MapPath("PulseClientSetup.msi"), 0);
string query = "select * from Property where Property = 'ProductVersion'";
WindowsInstaller.View view = db.OpenView(query);
view.Execute(null);
Record record = view.Fetch();
 
string version = record.get_StringData(2);
 
Response.Write("Version: " + version);

Open in new window

0
 
alaranAuthor Commented:
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now