Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
To get the keyname for the given values inside all the keys and sub keys in registery using c#
Posted

1 solution

This is a really nice one: http://snipplr.com/view/10315/[^]

But first of all read this: http://www.csharphelp.com/2007/01/registry-ins-and-outs-using-c/[^]

You need recursivity and this code snippet found by google for you will help also:

C#
private void  GetSubKeys(RegistryKey SubKey)
{
    /*
      here you can iterate the values in current subkey, and find what you want.
    */
    foreach(string sub in SubKey.GetSubKeyNames())
    {      
      RegistryKey local = Registry.Users;
      local = SubKey.OpenSubKey(sub,true);
      GetSubKeys(local); // By recalling itselfit makes sure it get all the subkey names
    }
}
//This is how we call the recursive function GetSubKeys
RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(@".DEFAULT\test",true);
GetSubKeys(OurKey);
 
Share this answer
 
v3
Comments
Zoltán Zörgő 25-Jun-12 11:13am    
why is the downvote?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900