views:

1010

answers:

2

I don't know what's going on here... but the Microsoft.Win32.Registry class is returning all kinds of strange stuff. When I say GetSubKeys it returns a bunch of things that aren't there in regedit (for example, I call Registry.LocalMachine.OpenSubKey("SOFTWARE").SubKeyCount and it returns "81"... but there are only 30 keys when I view it using regedit)

when I try to get the value of something it always returns null.

I have gone through the registry and set permissions on various keys to everyone:full just to test, but still nothing.

am I missing something? I did just upgrade to Windows7 Ultimate from a Vista Ultimate machine...

??

A: 

Since you're opening HKLM, you have to ask for read-only access if you're not running as an Administrator. Just opening the key may or may not work, as Windows can't be sure you're not trying to write to it.

Changing permissions is not the solution, as it just opens a security hole that MS has been trying to close since XP (where it was voluntary to run as non-administrator) and enforcing closure of since Vista's release (where the default is non-administrator).

See this question for a discussion of this subject. It pertains to Delphi, but contains some info and links that you might find useful.

Just out of curiosity, though... Why would an Excel add-in need to read or write to HKLM? Only an installer should be writing to that hive, and file associations are stored in HKCR or HKCU.

Ken White
there's no writing, only reading. So I don't understand... even if I try and explicitly say "I'm only reading this"... I still don't see the keys that are there in regedit. is it not supposed to show a "merged view": http://msdn.microsoft.com/en-us/library/aa965884(VS.85).aspx
Nick Franceschina
A: 

the actual answer:

http://stackoverflow.com/questions/869783/windows-64-bit-registry-v-s-32-bit-registry

since my laptop is 64bit and my app is 32bit... it was looking under

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\CompanyX

Nick Franceschina
You should accept this as your answer. You won't gain any reputation by doing so, but it'll let others know you've got a solution.
Ken White