If you are running a 32 bit app on a 64 bit machine (I am using windows 7) and you write this code
RegistryKey k开发者_如何学运维ey = Registry.LocalMachine.OpenSubKey(@"Software\XXX")
it will actually get the key from
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\XXX
and not
HKEY_LOCAL_MACHINE\SOFTWARE\XXX
Progromatically given a RegistryKey how do i work out the true path in the registry?
It is very much the True Path, a 32-bit app will always access the registry key in that subkey. Getting the value that a 64-bit app would see is technically possible, just not with .NET. You'll have to P/Invoke RegOpenKeyEx() et al so you can specify the KEY_WOW64_64KEY flag.
UPDATE: addressed in .NET 4.0 with RegistryKey.OpenBaseKey(). The RegistryView argument lets you specify the view you want. You'd use RegistryView.Registry64 in this case.
It is a function of whether or not the program was compiled for 32 or 64 bit Windows and whether it's running on 32 or 64 bit Windows. See if below helps:
http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/92f962d6-7f5e-4e62-ac0a-b8b0c9f552a3
精彩评论