tags:

views:

49

answers:

2

I have a c# application that runs on both 32-bit and 64-bit OS.In my app, how can I programatically check that solidworks is installed or not on computer.If we can check it by reading registry key ,then provide me path for both 32-bit and 64-bit.Tell me if there are other ways also to check it.

+1  A: 

You could use WMI as follows

private static bool IsInstalled(string ProductName)
{

    bool rv = false;
    ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
    ManagementObjectCollection Products = searcher.Get();
    if (Products.Count != 0)
    {
        foreach (ManagementObject product in Products)
        {
            if (product.Properties["Name"].Value.ToString() == ProductName)
            {
                rv = true;
            }
        }
    }
    return rv;           
}
Charles Gargent
I would throw 'using' statements around the ManagementObjectSearcher and ManagementObjectCollection to make sure they are disposed of properly.
SwDevMan81
A: 

You could use the Windows Installer API via PInvoke. See e.g. MsiEnumRelatedProducts

Taneli Waltari