Check Registry to see if it is installed : Registry « Development Class « C# / C Sharp






Check Registry to see if it is installed

        

using System;
using Microsoft.Win32;

class Utility
{
    public static bool IsInstalled(string uninstallProductName, string targetMachine)
    {
        RegistryKey regKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, targetMachine);
        RegistryKey tempKey;

        uninstallProductName = uninstallProductName.Trim().ToLower();

        regKey = regKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", false);

        foreach (string subKey in regKey.GetSubKeyNames())
        {
            tempKey = regKey.OpenSubKey(subKey, false);

            if (Array.IndexOf(tempKey.GetValueNames(), "DisplayName") >= 0)
            {
                if (tempKey.GetValue("DisplayName").ToString().ToLower()
                    .StartsWith(uninstallProductName))
                {
                    return true;
                }
            }
        }

        // no match
        return false;
    }
}

   
    
    
    
    
    
    
    
  








Related examples in the same category

1.Registry.LocalMachine
2.Write a Text and DWord Value to the Registry
3.Enumerating Registry Keys
4.Retrieve the CPU Type and Speed from the Registry
5.Use GetValue and SetValue to get and save value to Registry
6.Get the Registry key found for CurrentUser
7. Accessing the Registry
8.Open a SubKey in Registry
9.Get Registry value Get Registry value
10.Registry File Association
11.Get/Set User Registry
12.Copy Registry
13.Registry Utils
14.Retrieves any Registry value that uses the REGBINARY data type.
15.Writes a Registry value to the Registry.
16.Get IIS version