Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thephatp - 28 Mar 2008 03:26 GMT
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
Steve Gerrard - 28 Mar 2008 03:36 GMT
> This is incredibly strange.  I used regedit and went to
> HKEY_LOCAL_MACHINE and create a new subkey under "Software".  I added
[quoted text clipped - 10 lines]
> 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
thephatp - 28 Mar 2008 04:11 GMT
> > This is incredibly strange.  I used regedit and went to
> > HKEY_LOCAL_MACHINE and create a new subkey under "Software".  I added
[quoted text clipped - 17 lines]
>
> - 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
Family Tree Mike - 28 Mar 2008 13:02 GMT
> > > This is incredibly strange.  I used regedit and went to
> > > HKEY_LOCAL_MACHINE and create a new subkey under "Software".  I added
[quoted text clipped - 34 lines]
>
> 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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.