473,804 Members | 3,802 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Iterate through registry sub keys.

I am trying to read values to the subkeys under HKLM\...\Uninst all.

I get to this point...

RegistryKey Sftw = RegistryKey.Ope nRemoteBaseKey( RegistryHive.Lo calMachine,
name).OpenSubKe y("software").O penSubKey("Micr osoft").OpenSub Key("Windows"). OpenSubKey("Cur rentVersion").O penSubKey("Unin stall");

foreach (string SubKey in Sftw.GetSubKeyN ames())
{

}

and now I want to read some of the values to the subkeys. Nothing I have
tried works. All I have been able to accomplish is reading the name of the
subkey itself.

I feel I am missing something here...

Thanks for any assistance!
Nov 17 '05 #1
4 6714
James,

You say it doesn't work. Are you sure you have permission to access
those keys? Also, do you get an exception, or it doesn't return the value
that you think you should get?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"James" <Ja***@discussi ons.microsoft.c om> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
I am trying to read values to the subkeys under HKLM\...\Uninst all.

I get to this point...

RegistryKey Sftw =
RegistryKey.Ope nRemoteBaseKey( RegistryHive.Lo calMachine,
name).OpenSubKe y("software").O penSubKey("Micr osoft").OpenSub Key("Windows"). OpenSubKey("Cur rentVersion").O penSubKey("Unin stall");

foreach (string SubKey in Sftw.GetSubKeyN ames())
{

}

and now I want to read some of the values to the subkeys. Nothing I have
tried works. All I have been able to accomplish is reading the name of
the
subkey itself.

I feel I am missing something here...

Thanks for any assistance!

Nov 17 '05 #2
I'm guessing I just don't know the method to read the subkeys. The only
value I have been able to figure out how to return is the name of the
subkeys... I did try this...

foreach (RegKey SubKey in Sftw.GetSubKeyN ames())
{
Console.WriteLi ne(SubKey.GetVa lue("DisplayNam e").ToString()) ;
}

and caught an error converting string to registrykey.

"Nicholas Paldino [.NET/C# MVP]" wrote:
James,

You say it doesn't work. Are you sure you have permission to access
those keys? Also, do you get an exception, or it doesn't return the value
that you think you should get?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"James" <Ja***@discussi ons.microsoft.c om> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
I am trying to read values to the subkeys under HKLM\...\Uninst all.

I get to this point...

RegistryKey Sftw =
RegistryKey.Ope nRemoteBaseKey( RegistryHive.Lo calMachine,
name).OpenSubKe y("software").O penSubKey("Micr osoft").OpenSub Key("Windows"). OpenSubKey("Cur rentVersion").O penSubKey("Unin stall");

foreach (string SubKey in Sftw.GetSubKeyN ames())
{

}

and now I want to read some of the values to the subkeys. Nothing I have
tried works. All I have been able to accomplish is reading the name of
the
subkey itself.

I feel I am missing something here...

Thanks for any assistance!


Nov 17 '05 #3
James,

I see it now. You will have to open each sub key, you can't just cast
it to a registry key. You need to do this:

foreach (string subKeyName in Sftw.GetSubKeyN ames())
{
// Open the key.
using (RegistryKey subKey = Sftw.OpenSubKey (subKeyName))
{
// Write the value.
Console.WriteLi ne(subKey.GetVa lue("DisplayVal ue").ToString() );
}
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"James" <Ja***@discussi ons.microsoft.c om> wrote in message
news:03******** *************** ***********@mic rosoft.com...
I'm guessing I just don't know the method to read the subkeys. The only
value I have been able to figure out how to return is the name of the
subkeys... I did try this...

foreach (RegKey SubKey in Sftw.GetSubKeyN ames())
{
Console.WriteLi ne(SubKey.GetVa lue("DisplayNam e").ToString()) ;
}

and caught an error converting string to registrykey.

"Nicholas Paldino [.NET/C# MVP]" wrote:
James,

You say it doesn't work. Are you sure you have permission to access
those keys? Also, do you get an exception, or it doesn't return the
value
that you think you should get?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"James" <Ja***@discussi ons.microsoft.c om> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
>I am trying to read values to the subkeys under HKLM\...\Uninst all.
>
> I get to this point...
>
> RegistryKey Sftw =
> RegistryKey.Ope nRemoteBaseKey( RegistryHive.Lo calMachine,
> name).OpenSubKe y("software").O penSubKey("Micr osoft").OpenSub Key("Windows"). OpenSubKey("Cur rentVersion").O penSubKey("Unin stall");
>
> foreach (string SubKey in Sftw.GetSubKeyN ames())
> {
>
> }
>
> and now I want to read some of the values to the subkeys. Nothing I
> have
> tried works. All I have been able to accomplish is reading the name of
> the
> subkey itself.
>
> I feel I am missing something here...
>
> Thanks for any assistance!


Nov 17 '05 #4
That made the difference... I saw the keyword using in the MSDN examples I
just could not see how to apply it here. Thanks for your help!

"Nicholas Paldino [.NET/C# MVP]" wrote:
James,

I see it now. You will have to open each sub key, you can't just cast
it to a registry key. You need to do this:

foreach (string subKeyName in Sftw.GetSubKeyN ames())
{
// Open the key.
using (RegistryKey subKey = Sftw.OpenSubKey (subKeyName))
{
// Write the value.
Console.WriteLi ne(subKey.GetVa lue("DisplayVal ue").ToString() );
}
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"James" <Ja***@discussi ons.microsoft.c om> wrote in message
news:03******** *************** ***********@mic rosoft.com...
I'm guessing I just don't know the method to read the subkeys. The only
value I have been able to figure out how to return is the name of the
subkeys... I did try this...

foreach (RegKey SubKey in Sftw.GetSubKeyN ames())
{
Console.WriteLi ne(SubKey.GetVa lue("DisplayNam e").ToString()) ;
}

and caught an error converting string to registrykey.

"Nicholas Paldino [.NET/C# MVP]" wrote:
James,

You say it doesn't work. Are you sure you have permission to access
those keys? Also, do you get an exception, or it doesn't return the
value
that you think you should get?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"James" <Ja***@discussi ons.microsoft.c om> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
>I am trying to read values to the subkeys under HKLM\...\Uninst all.
>
> I get to this point...
>
> RegistryKey Sftw =
> RegistryKey.Ope nRemoteBaseKey( RegistryHive.Lo calMachine,
> name).OpenSubKe y("software").O penSubKey("Micr osoft").OpenSub Key("Windows"). OpenSubKey("Cur rentVersion").O penSubKey("Unin stall");
>
> foreach (string SubKey in Sftw.GetSubKeyN ames())
> {
>
> }
>
> and now I want to read some of the values to the subkeys. Nothing I
> have
> tried works. All I have been able to accomplish is reading the name of
> the
> subkey itself.
>
> I feel I am missing something here...
>
> Thanks for any assistance!


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4301
by: vbMark | last post by:
Hello, In regards to the Registry... Can someone give me an example of how to list an unknown number of subkeys under a key, and put the key names in one column of a listbox, and the key values in another column of a listbox? Thanks!
21
10838
by: Kevin Swanson | last post by:
I'm attempting some remote registry manipulation via C#. I've written a test app to simply grab a specified key from a specified hive on a specified machine. The call to OpenSubKey is throwing System.SecurityException. Also of note: Sitting at my local box, I can open regedit and connect to the remote registry. I see three hives: _CLASSES_ROOT, _LOCAL_MACHINE, and _USERS. I can open all but HKEY_LOCAL_MACHINE. When I try to expand that...
0
1265
by: Jigar Mehta | last post by:
Hye, any idea about iterating through registry keys??? how to do that... code snippet will help me a lot... -- Jigar Mehta jbmehtain@yahoo.co.in
4
9118
by: Kevin L | last post by:
I store some application settings in the registry under HKEY_LOCAL_MACHINE\Software\MyApplication I want to allow full access to this key and subkeys. Currently, I manually change the permissions on the keys. How can I accomplish this through code?
9
2093
by: Newbie Coder | last post by:
Hello Newsgroup Readers I would like to know how to go & do the following: I have a certain registry key that has sub values Example: Key1 http://www.microsoft.com Key2 http://www.sarc.com
3
2261
by: lazy | last post by:
I have a berkely db and Im using the bsddb module to access it. The Db is quite huge (anywhere from 2-30GB). I want to iterate over the keys serially. I tried using something basic like for key in db.keys() but this takes lot of time. I guess Python is trying to get the list of all keys first and probbaly keep it in memory. Is there a way to avoid this, since I just want to access keys serially. I mean is there
0
4645
by: Gary | last post by:
I'm having trouble entering Additional Registry Keys into my Package Solution that will deploy the Access 2007 runtime. (Client machine is running XP with Office 2007 Standard.) The Package Solution Wizard, on about page 3, has a section for entering Additional Registry Keys. I want to include a locations key that will identify my install directory as a Trusted Location, thereby turning off the Security Alert when users open the ACCDR. ...
11
7561
by: Unknown Hero | last post by:
Tim Golden wrote: The first link which points to the Python documentation for the _winreg module I already checked, even before coming here. I am wondering how I should do the loop I need (go through HKEY_LOCAL_MACHINE and read one subkey at a time, if it contains this 'foo' then change it into 'moo'). As I already said, I am by no means an expert in Python (heck, I learned the basics only a month ago). However, I am willing to learn.
12
5647
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i current have a way to read both local and remote machines registry keys and create a textual view (.txt output). i now looking for ways to do export of local and remote mahcine registry keys into ".reg" file format via C#. is this do able? what do i need to research to do this? or is where i need to windows WinApi?
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10569
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10325
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10075
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.