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