473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 3566

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: geek_in_a_box | last post by:
I seem to be experiencing a behavior on Framework 1.0 sp2 RegistryKey class where the class is not releasing/closing named pipe winreg handles to remote machines. The process continues to hold on...
1
by: R Agam | last post by:
Hi How can I tell what type of value (string, int, ...) is returned from a call to RegistryKey.GetValue? Thanks, Ronen
3
by: Bryan | last post by:
We created a Windows Service with C#. The service will start OK on computers that are a member of a domain, but when we try to start it on a server that is configured for a workgroup we get the...
7
by: Bob | last post by:
I'm working on a Windows app that needs to write to the Registry HKLM. I keep getting a "System.UnauthorizedAccessException: Cannot write to the registry key." error when running the app. I'm...
0
by: csharp_helpwanted | last post by:
steps.. first, I'm creating a connection by mapping a network drive to the pc second, the map drive connection was successful I try to read a certian registry key/value (that is a valid reg...
0
by: g82martin | last post by:
I am using the RegistryKey class to access the registry on remote machines. I only require read access. I am able to successfully read registry keys under HKLM\Software\Microsoft\Windows...
1
by: Brian Keating | last post by:
Hi there anyone know to the get the native registry Handle from a RegistryKey? thanks in advance
5
by: Steve Bottoms | last post by:
Hi, all... Trying to determine how to check the state of OpenSubKey when called. What is the return value if the requested subkey doesn't exist?? I try a GetType on the result but only get a...
4
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Here is my problem. I have a program that will create a registry key, however it is not and here is the code and also the error that follows: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.