473,396 Members | 2,016 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.

Registry.LocalMachine.OpenSubKey(...) is returning NULL

This is incredibly strange. I used regedit and went to
HKEY_LOCAL_MACHINE and create a new subkey under "Software". I added
a few more, then went into code to try to read them. I kept getting
null returned when I tried to open them, so I decided to try this:

Registry.LocalMachine.GetSubKeyNames()

The results where dumbfounding--they did NOT match what I see in the
Registry under HKEY_LOCAL_MACHINE. The list values returned from the
Registry.LocalMachine.GetSubKeyNames() method is MUCH longer than the
list of subkeys that exist in the registry.

What gives? (I'm really hoping this is an easy explanation for
someone, but I'm just not getting it.)

Also, I'm having another, just as concerning problem. In both the
Registry and in code from the list returned by GetSubKeyNames, the
subkey "Microsoft" exists. However, notice the following:

RegistryKey key1 = Registry.LocalMachine.OpenSubKey( "Software" ); //
This returns the key -- Success
RegistryKey key2 = Registry.LocalMachine.OpenSubKey( "Software\
\Microsoft" ); // This returns NULL :(
RegistryKey key3 = key1.OpenSubKey( "Microsoft" ) ; // This also
returns NULL :(

Why could this be happening?

Thanks in advance!

Chad
Mar 28 '08 #1
3 23686
thephatp wrote:
This is incredibly strange. I used regedit and went to
HKEY_LOCAL_MACHINE and create a new subkey under "Software". I added
a few more, then went into code to try to read them. I kept getting
null returned when I tried to open them, so I decided to try this:

Registry.LocalMachine.GetSubKeyNames()

The results where dumbfounding--they did NOT match what I see in the
Registry under HKEY_LOCAL_MACHINE. The list values returned from the
Registry.LocalMachine.GetSubKeyNames() method is MUCH longer than the
list of subkeys that exist in the registry.

What gives? (I'm really hoping this is an easy explanation for
someone, but I'm just not getting it.)
Vista, by chance?

If so, you may want to look up Registry
Virtualization...http://msdn2.microsoft.com/en-us/library/aa965884.aspx
Mar 28 '08 #2
On Mar 27, 9:36*pm, "Steve Gerrard" <mynameh...@comcast.netwrote:
thephatp wrote:
This is incredibly strange. *I used regedit and went to
HKEY_LOCAL_MACHINE and create a new subkey under "Software". *I added
a few more, then went into code to try to read them. *I kept getting
null returned when I tried to open them, so I decided to try this:
Registry.LocalMachine.GetSubKeyNames()
The results where dumbfounding--they did NOT match what I see in the
Registry under HKEY_LOCAL_MACHINE. *The list values returned from the
Registry.LocalMachine.GetSubKeyNames() method is MUCH longer than the
list of subkeys that exist in the registry.
What gives? *(I'm really hoping this is an easy explanation for
someone, but I'm just not getting it.)

Vista, by chance?

If so, you may want to look up Registry
Virtualization...http://msdn2.microsoft.com/en-us/library/aa965884.aspx- Hide quoted text -

- Show quoted text -
Yes, of course. :(

That is SO LAME. Does this mean that I need to set app settings for
ALL users at install? What happens when a new user is created? I
need to edit the registry and create some default app settings, and I
obviously want these defaults to apply to all users.

If it's in the article, forgive me. I'm planning on reading it
tomorrow.

But even at a glance, I saw the big difference (redirect to users
location). :(

Thanks for the link!

Chad
Mar 28 '08 #3


"thephatp" wrote:
On Mar 27, 9:36 pm, "Steve Gerrard" <mynameh...@comcast.netwrote:
thephatp wrote:
This is incredibly strange. I used regedit and went to
HKEY_LOCAL_MACHINE and create a new subkey under "Software". I added
a few more, then went into code to try to read them. I kept getting
null returned when I tried to open them, so I decided to try this:
Registry.LocalMachine.GetSubKeyNames()
The results where dumbfounding--they did NOT match what I see in the
Registry under HKEY_LOCAL_MACHINE. The list values returned from the
Registry.LocalMachine.GetSubKeyNames() method is MUCH longer than the
list of subkeys that exist in the registry.
What gives? (I'm really hoping this is an easy explanation for
someone, but I'm just not getting it.)
Vista, by chance?

If so, you may want to look up Registry
Virtualization...http://msdn2.microsoft.com/en-us/library/aa965884.aspx- Hide quoted text -

- Show quoted text -

Yes, of course. :(

That is SO LAME. Does this mean that I need to set app settings for
ALL users at install? What happens when a new user is created? I
need to edit the registry and create some default app settings, and I
obviously want these defaults to apply to all users.

If it's in the article, forgive me. I'm planning on reading it
tomorrow.

But even at a glance, I saw the big difference (redirect to users
location). :(

Thanks for the link!

Chad
Be aware that registry virtualization not only occurs in Vista, but with 64
bit OS such as XP.

Regarding user settings, they should be stored under the HKEY_CURRENT_USER
path. If the user's settings are not found when the code is launched (such
as a new user is added to the computer), then copy from the safe place such
as HKEY_LOCAL_MACHINE. This way you are only reading from HKLM. Hopefully I
understood your concern correctly.
Mar 28 '08 #4

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

Similar topics

0
by: Sara | last post by:
We have a Cobol stored procedures on DB2 OS/390. We are able to access the stored procedures from a distributed platform Windows 2000/ Linux / Unix using DB2 Connect. But it does not return column...
0
by: Atul | last post by:
I have a .Net Managed C++ wrapper control for a MFC control. When using the ..Net control in a Visual Studio 2005 Beta 2 C# project and running in Debug mode, I get a crash saying something like...
0
by: George Durzi | last post by:
cross posted in datagrid group. Inside <columns/> in my datagrid, I have the following template column <asp:templatecolumn HeaderText="To Be Completed By"> <itemtemplate> <asp:Label...
2
by: cr | last post by:
Hello. I have a C# (Windows forms) project that uses OpenSubKey to write some values to a registry key. Here's the code: // Create the Installation registry key and values...
9
by: Thomas Mlynarczyk | last post by:
Hi, It seems to be a generally adopted convention to have a function return FALSE in case of an error. But if a function is supposed to return a boolean anyway, one cannot distinguish anymore...
3
by: Peri | last post by:
I can delete RCan't delete Registry.LocalMachine subkeyegistry.LocalMachine subkey using regedit. But not using code: RegistryKey eurotaxKey =...
1
by: =?Utf-8?B?SGFuIFFpYW8=?= | last post by:
Hi, I'm trying to open this key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications", and "HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\MUICache" but it returns me null. Anyone...
1
by: sbowman | last post by:
I have the following CASE statement in a view: (SELECT CASE WHEN ISNULL(.., NULL) = NULL THEN .(..) ELSE .(..) + ', ' + .. END) AS ContactNameAndTitle It works perfectly when...
2
by: aaronharwood | last post by:
I have read dozens of existing responses on threads, that span the last 5 years or so, concerning this problem and while there are many solutions that appear to work for others - none work for me. ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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,...
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.