471,610 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 software developers and data experts.

RegistryKey member GetValueNames

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
2 3462

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
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.

Similar topics

reply views Thread by geek_in_a_box | last post: by
1 post views Thread by R Agam | last post: by
reply views Thread by csharp_helpwanted | last post: by
reply views Thread by g82martin | last post: by
1 post views Thread by Brian Keating | last post: by
4 posts views Thread by eSolTec, Inc. 501(c)(3) | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.