none
Populate Specific Registry Keys in Combobox RRS feed

  • Question

  • Hi,

    I have my registry key HKEY_LOCAL_MACHINE\Software\Jassim

    Under Jassim key, I have list of keys, e.g. system1, system2, options, etc

    System1 and System2 wil have SystemGUID value where options key will not have.


    I want to loop through all keys under Jassim key and found every key which has a SystemGUID key in it to list it in a Combobox?

    How can I do this please?

    Thanks,
    Jassim​

    Wednesday, December 3, 2014 5:42 AM

Answers

  • Hello Jassim​,

    >>I want to loop through all keys under Jassim key and found every key which has a SystemGUID key in it to list it in a Combobox?

    Not sure if the SystemGUID is a value or a sub key of System1 and System2, you could check this demo example for both scenario:

    List<RegistryKey> keyContainsGuid = new List<RegistryKey>();
    
                    using (RegistryKey baseKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\BMX"))
    
                    {
    
                        foreach (string subKeyName in baseKey.GetSubKeyNames())
    
                        {
    
                            using (RegistryKey tempKey = baseKey.OpenSubKey(subKeyName))
    
                            {
    
                                //if the SystemGUID is value name, you could use this
    
                                if (tempKey.GetValueNames().Contains("SystemGUID"))
    
                                {
    
                                    keyContainsGuid.Add(tempKey);
    
                                }
    
                                //if the SystemGUID is sub key name, you could use this
    
                                if (tempKey.GetSubKeyNames().Contains("SystemGUID"))
    
                                {
    
                                    keyContainsGuid.Add(tempKey);
    
                                }
    
                            }
    
                        }
    
    
                    }
    


    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 4, 2014 6:25 AM
    Moderator