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





"thephatp" wrote:

On Mar 27, 9:36 pm, "Steve Gerrard" <mynameh...@xxxxxxxxxxx> wrote:
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.
.



Relevant Pages

  • Re: Compiling DLL & Vista: Follow up
    ... I've been studying Vista all day. ... running as an Admin or setting a program to run as Admin will ... The biggest problem I've found in my cool little registry hack to register ... Try reading the Vista newsgroups....lots of complaining about the UAC. ...
    (microsoft.public.vb.general.discussion)
  • Re: Registry.LocalMachine.OpenSubKey(...) is returning NULL
    ... Registry under HKEY_LOCAL_MACHINE. ... ALL users at install? ... need to edit the registry and create some default app settings, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: App Settings in Vista
    ... user account controll is active in vista?! ... problem to write my app settings to the registry. ...
    (microsoft.public.vc.language)
  • Save setting to registry using C#
    ... In VB.Net I do this to save my app settings: ... In my C# migration efforts I have encountered yet another struggle -- ... registry by experimenting I thought I would just ask -- what is the way ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Which registry key to use?
    ... My app stores preferences in HKEY_CURRENT_USER. ... Which registry key should I use? ... Use an INI file or other external storage for app settings; ... VB.Net: "Fool me once..." ...
    (microsoft.public.vb.general.discussion)