473,793 Members | 2,927 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 23771
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
1555
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
2118
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
2204
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
2473
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
5214
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
7842
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
3562
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
7471
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
2540
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
9518
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
10430
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
10211
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...
1
10159
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,...
1
7538
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
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
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
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.