locked
RegistryKey Class - GetSubKeyNames() is missing SubKeyNames that are in Registry RRS feed

  • Question

  • I am using the following code to iterate all the SubKeyNames under the Uninstall folder in registry.

    String registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
    RegistryKey key = Registry.LocalMachine.OpenSubKey(registryKey);
    foreach (string subkeyname in key.GetSubKeyNames())
    {
    RegistryKey subkey = key.OpenSubKey(subkeyname);
    }

    Some of the SubKeyNames are missing from the retrieved string array.
    I have tried to check why this is the case, but not successful yet.
    I have checked using the 64 and 32 bit methods, but the missing items are 64 bit programs located in the specified Registry folder.
    The specific entries missing, that I am seeking to find here, are for Oracle MySQL Version 5.5.x, which has a SubKeyName in the format:
    {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    I was expecting to be able to interrogate this SubKeyName and get its properties, but this key value does not appear in the GetSubKeyNames list at all.
    Hoping someone can advise what I am doing wrong here.

    Thanks.

           
    Saturday, June 23, 2018 6:49 AM

Answers

  • I get the keys with x86 on x 64 with :

    using (var rootKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
    {
        using (var key = rootKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", false))
        {
            foreach (string subkeyname in key.GetSubKeyNames())
            {
                Console.WriteLine("{0}", subkeyname);
            }    
        }
    }

    • Marked as answer by Mr Cheese Saturday, June 23, 2018 8:14 AM
    Saturday, June 23, 2018 8:04 AM

All replies

  • I get the keys with x86 on x 64 with :

    using (var rootKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
    {
        using (var key = rootKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", false))
        {
            foreach (string subkeyname in key.GetSubKeyNames())
            {
                Console.WriteLine("{0}", subkeyname);
            }    
        }
    }

    • Marked as answer by Mr Cheese Saturday, June 23, 2018 8:14 AM
    Saturday, June 23, 2018 8:04 AM
  • I used the code you posted, and I can now see my missing SubKeyName in the array result.
    Now I can proceed to start the next steps.
    Thanks for your post.
    Saturday, June 23, 2018 8:18 AM