Click here to Skip to main content
Sign Up to vote bad
good
See more: C#Windows
To get the keyname for the given values inside all the keys and sub keys in registery using c#
Posted 13 Jun '12 - 7:22


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:
 
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);
  Permalink  
Comments
Zoltán Zörgő - 25 Jun '12 - 11:13
why is the downvote?

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 449
1 Arun Vasu 253
2 OriginalGriff 210
3 CPallini 163
4 Aarti Meswania 158
0 Sergey Alexandrovich Kryukov 10,129
1 OriginalGriff 7,749
2 CPallini 4,181
3 Rohan Leuva 3,482
4 Maciej Los 2,999


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 13 Jun 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid