tags:

views:

26

answers:

1

I was wondering if it is possible to retreive from Windows a list of the applications installed INCLUDING their GUID and Upgrade GUID. I am having problems getting my upgrade to work for one of my programs, and need to check these values for the old version of the program. Thanks for the help!

+1  A: 

You can use MSI api functions to enumerate all installed products and to query their properties. If you replace MsiGetProductInfo with MsiGetProductInfoEx you will be able to query additional information such as the installation context or user SID associated for an installation.

However, this does not allow you to enumerate the UpgradeCode. As far as I know MSI doesn't keep a record associating a ProductCode with an UpgradeCode; only the reverse mapping is available and you can enumerate the products related to an UpgradeCode using the MsiEnumRelatedProducts function.

Below you will find sample code which enumerates the installed or advertised products and their ProductCode using C#:

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

class Program
{
    [DllImport("msi.dll", CharSet = CharSet.Unicode)]
    static extern Int32 MsiGetProductInfo(string product, string property,
        [Out] StringBuilder valueBuf, ref Int32 len);

    [DllImport("msi.dll", SetLastError = true)]
    static extern int MsiEnumProducts(int iProductIndex,
        StringBuilder lpProductBuf);

    static void Main(string[] args)
    {
        StringBuilder sbProductCode = new StringBuilder(39);
        int iIdx = 0;
        while (MsiEnumProducts(iIdx++, sbProductCode) == 0)
        {
            Int32 productNameLen = 512;
            StringBuilder sbProductName = new StringBuilder(productNameLen);

            MsiGetProductInfo(sbProductCode.ToString(),
                "ProductName", sbProductName, ref productNameLen);

            Console.WriteLine("Product: {0}\t{1}", sbProductName, sbProductCode);
        }
    }
}

Update

If you still have the MSI installer of the previous version you can simply open the file using Orca and search for the UpgradeCode.

0xA3
I have of course opened up the MSI with Orca and everything checks out, but I just wanted to check directly with Windows to see if anything strange happened during the initial install. The upgrade codes are the same and the upgrade just isn't working. See http://stackoverflow.com/questions/3863171/wix3-major-upgrade-not-working
Adkins