2

I am trying to retrieve the product version of an installed msi using upgrade code. I tried using MsiGetProductInfo api but it doesn't return me the result.

I couldn't find the application under HKEY_LOCAL_MACHINE\SOFTWARE\MSFT\Windows\CurrentVersion\Uninstall.

But Instead I did find my application some place else in registry under Installer\Products.

I know that similar question has bben asked here: Get Product Code of installed Msi

but does someone has a better way of doing it.

Thanks

Community
  • 1
  • 1
alice7
  • 3,834
  • 14
  • 64
  • 93
  • http://stackoverflow.com/questions/7374646/reading-current-installed-version-of-an-application-using-windows-api – alice7 Oct 28 '11 at 18:32
  • This is how I solved. http://stackoverflow.com/questions/7374646/reading-current-installed-version-of-an-application-using-windows-api – alice7 Oct 28 '11 at 18:32

1 Answers1

1

I had pretty much the same issue just now. If you have the upgrade-code GUID, you can do this:

WindowsInstaller.Installer installer =
   Activator.CreateInstance(/* left as an exercise for the reader */);
foreach (string productCode in installer.get_RelatedProducts("your-upgradecode-guid")) {
   string productVersion = installer.get_ProductInfo(productCode, "VersionString");
}

Trouble is, there could be multiple related products, so how you handle that is up to you.

EDIT: If you install per-user by default or by mistake, then you might not get the product code with RelatedProducts if you run the query as a different user than the MSI was installed for... even if the installation was more or less public.

Greg
  • 906
  • 1
  • 9
  • 22