registry key

G

Guest

hi,
i've a requirement to scan the registry keys programatically in a console
application and read the data of the keys..
given a registry key, say,"HKEY_USERS". user should be able to scan the
subkeys of the given key recursively(i.e. all the subkeys of the given
subkeys etcc..) till the last indent level....

i've used a recursion to do so..but it's taking lot of time..
is there any efficient way to acheive it.....
 
M

Mark Rae [MVP]

in a console application

This is an ASP.NET newsgroup - you'll generally get better responses by
posting in the correct group...

Anyway...
given a registry key, say,"HKEY_USERS". user should be able to scan the
subkeys of the given key recursively(i.e. all the subkeys of the given
subkeys etcc..) till the last indent level....

i've used a recursion to do so..but it's taking lot of time..
is there any efficient way to acheive it.....

Dictionary<string, string> dicSubKeyNamesAndValues = new Dictionary<string,
string>();
using (RegistryKey objRegKey =
RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, "<machine name>"))
{
using (RegistryKey objSubKey = objRegKey.OpenSubKey("<key to start
from">))
{
if (objSubKey!= null)
{
foreach (string strSubKey in objSubKey.GetValueNames())
{
dicSubKeyNamesAndValues.Add(strSubKey,
objRegKey.GetValue(strSubKey).ToString());
}
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top