Enumerating Registry Keys

image_pdfimage_print
   



using System;
using Microsoft.Win32;

class Class1 {
    static void Main(string[] args) {
        RegistryKey myRegKey = Registry.LocalMachine;
        myRegKey = myRegKey.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionUninstall");
        String[] subkeyNames = myRegKey.GetSubKeyNames();
        foreach (String s in subkeyNames) {
            RegistryKey UninstallKey = Registry.LocalMachine;
            UninstallKey = UninstallKey.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionUninstall" + s);
            try {
                Object oValue = UninstallKey.GetValue("DisplayName");
                Console.WriteLine(oValue.ToString());
            } catch (NullReferenceException) {
            }
        }
    }
}