By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,018 Members | 870 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,018 IT Pros & Developers. It's quick & easy.

RegistryKey member GetValueNames

P: n/a
being a novice i searched the net to get help on my c# project.

i'm trying to iterate, enumerate, loop through a registry tree hive. for
example i have a sub folder under HKLM\SOFTWARE that has some 21 sub folders
and there are sub folders under some of he 21.

i have no problem going into the sub folder (lets call it) programX. when i
do an readkeys.opensubkey(regipath) and then keyvalue.getvalue(...) it will
not only read the "values" but it will try to enumerate through the sub
folders if they are present. this does not make sense. the question is is
this normal that the "getvalue()" in "RegistryKey" class suppose to get the
sub folders under the folder?

when i try to do this on a single folder with multiple sub folders it get
everything. but is i start at the main key "hklm\software\programX" it only
gets the first sub folders of all the hive... ???
Jan 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

auldh wrote:
being a novice i searched the net to get help on my c# project.

i'm trying to iterate, enumerate, loop through a registry tree hive. for
example i have a sub folder under HKLM\SOFTWARE that has some 21 sub folders
and there are sub folders under some of he 21.

i have no problem going into the sub folder (lets call it) programX. when i
do an readkeys.opensubkey(regipath) and then keyvalue.getvalue(...) it will
not only read the "values" but it will try to enumerate through the sub
folders if they are present. this does not make sense. the question is is
this normal that the "getvalue()" in "RegistryKey" class suppose to get the
sub folders under the folder?

when i try to do this on a single folder with multiple sub folders it get
everything. but is i start at the main key "hklm\software\programX" it only
gets the first sub folders of all the hive... ???


I'm guessing what you really want is GetSubKeyNames()

Given the list of subkeys (which is NON-recursive), you can then get
the
key value for each of them.

Matt

Jan 26 '06 #2

P: n/a
well i guess i should have included the function to help give a visual on
this.
====
private static void GetKeysValue(RegistryKey szKSubKey)
{
long lvalues, lsubs;
foreach(string Vsub in szKSubKey.GetSubKeyNames())
{
RegistryKey tempKey = szKSubKey.OpenSubKey(Vsub);
Console.WriteLine("\nThere are {0} keys for {1};",
tempKey.ValueCount.ToString(),
tempKey.Name);
foreach( string valueName in tempKey.GetValueNames())
{
lvalues = tempKey.ValueCount;
lsubs = tempKey.SubKeyCount;
object tempValue = tempKey.GetValue(valueName);
string stringValue = tempValue as String;
//test for string
if(stringValue !=null)
{
//MessageBox.Show(valueName + " " + tempKey.GetValue
(valueName).ToString());
Console.WriteLine("\tValue name: {0} ValueName: {1}",
valueName,
tempKey.GetValue(valueName).ToString());
}
else
{
===

i am using "GetSubKeyName" first then trying to get the keys and their
values but the collection also returns the "sub folders" but then it does not
do them all. odd thing i would not expect to see any sub folders in the
"getvaluenames" and "getvalues". it almost iterates through this loop
multiple times trying to get valuse and the sub folders.

"Matt" wrote:

auldh wrote:
being a novice i searched the net to get help on my c# project.

i'm trying to iterate, enumerate, loop through a registry tree hive. for
example i have a sub folder under HKLM\SOFTWARE that has some 21 sub folders
and there are sub folders under some of he 21.

i have no problem going into the sub folder (lets call it) programX. when i
do an readkeys.opensubkey(regipath) and then keyvalue.getvalue(...) it will
not only read the "values" but it will try to enumerate through the sub
folders if they are present. this does not make sense. the question is is
this normal that the "getvalue()" in "RegistryKey" class suppose to get the
sub folders under the folder?

when i try to do this on a single folder with multiple sub folders it get
everything. but is i start at the main key "hklm\software\programX" it only
gets the first sub folders of all the hive... ???


I'm guessing what you really want is GetSubKeyNames()

Given the list of subkeys (which is NON-recursive), you can then get
the
key value for each of them.

Matt

Jan 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.