473,884 Members | 2,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Registry.LocalM achine.OpenSubK ey(...) is returning NULL

This is incredibly strange. I used regedit and went to
HKEY_LOCAL_MACH INE 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.LocalM achine.GetSubKe yNames()

The results where dumbfounding--they did NOT match what I see in the
Registry under HKEY_LOCAL_MACH INE. The list values returned from the
Registry.LocalM achine.GetSubKe yNames() 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.LocalM achine.OpenSubK ey( "Software" ); //
This returns the key -- Success
RegistryKey key2 = Registry.LocalM achine.OpenSubK ey( "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 23781
thephatp wrote:
This is incredibly strange. I used regedit and went to
HKEY_LOCAL_MACH INE 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.LocalM achine.GetSubKe yNames()

The results where dumbfounding--they did NOT match what I see in the
Registry under HKEY_LOCAL_MACH INE. The list values returned from the
Registry.LocalM achine.GetSubKe yNames() 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...@com cast.netwrote:
thephatp wrote:
This is incredibly strange. *I used regedit and went to
HKEY_LOCAL_MACH INE 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.LocalM achine.GetSubKe yNames()
The results where dumbfounding--they did NOT match what I see in the
Registry under HKEY_LOCAL_MACH INE. *The list values returned from the
Registry.LocalM achine.GetSubKe yNames() 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...@com cast.netwrote:
thephatp wrote:
This is incredibly strange. I used regedit and went to
HKEY_LOCAL_MACH INE 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.LocalM achine.GetSubKe yNames()
The results where dumbfounding--they did NOT match what I see in the
Registry under HKEY_LOCAL_MACH INE. The list values returned from the
Registry.LocalM achine.GetSubKe yNames() 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_US ER
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_MACH INE. 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
1556
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 names. It returns only column numbers. When we try to retrieve the metadata of resultset , it is returning NULL for column names or any other meta data from ResultSetMetaData Object. Can you please advise how to resolve this problem. Thanks...
0
2122
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 "First Chance Exception : memory cannot be read". I found that this was becuase a call to AfxGetThread() was returning NULL. I tried using AFX_MANAGE_STATE(AfxGetStaticModuleState()); but it did not solve the problem. Furthermore, this crash only...
0
2210
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 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FULL_NAME") %>'><asp:label> </itemtemplate> <edititemtemplate>
2
2475
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 Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\Company\\Produ ct\\1.0\\Installation"); Microsoft.Win32.RegistryKey install = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Company\\Product
9
5222
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 between the "normal" FALSE and the "error" FALSE. So why not using NULL instead to indicate an error? Are there drawbacks I am not aware of? Greetings, Thomas
3
7855
by: Peri | last post by:
I can delete RCan't delete Registry.LocalMachine subkeyegistry.LocalMachine subkey using regedit. But not using code: RegistryKey eurotaxKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\Application\Eurotax"); eurotaxKey.DeleteSubKey("pathDat"); I am administrator and regedit shows me that 'Administrators' have full control on Eurotax key. I've also given 'All users' full control to this key and
1
3585
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 know why is that so? Thanks in advance.
1
7472
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 dbo.tblContact.JobTitleID is NOT null. When it
2
2543
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. I have some Javascript that is receiving an XML file from a Servlet. The problem is that the XMLResponse always returns a null value. Here is some the code snippet: ... function alertContents() { if (http_request.readyState == 4) { ...
0
9799
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11167
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...
1
10868
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
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
9591
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...
1
7984
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7137
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
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4231
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.