1
using Microsoft.Win32;

...


  string keyname = "HKEY_LOCAL_MACHINE\\Software\\[REST_OF_PATH]
  string value = "ServiceAddress";
  string default = "";
  string stringValue = (string)Registry.GetValue(keyname, value, default);

On my x64 machine, this works fine (on my x64 machine) when I build with x64 or AnyCPU, but stringValue is null when built with an x86 configuration.

I get similar results when I call Registry.LocalMachine.OpenSubKey

Is it possible to get this to work with an x86 build?

PortMan
  • 4,205
  • 9
  • 35
  • 61

1 Answers1

2

The 32-bit registry is stored under Wow6432Node. You have probably created your key under HKEY_LOCAL_MACHINE directly, which is the 64-bit portion of the registry. The registry redirector handles redirecting registry operations performed by 32-bit applications.

If you wish to access the 64-bit portion of the registry from a 32-bit application, you need to pass the flag KEY_WOW64_64KEY (0x0100) along with your access permissions when opening the key.

Dark Falcon
  • 43,592
  • 5
  • 83
  • 98