views:

55

answers:

2

If you are running a 32 bit app on a 64 bit machine (I am using windows 7) and you write this code

RegistryKey key = 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?

A: 

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

fupsduck
A: 

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.

Hans Passant