Search code examples
c#.netwinapi.net-2.0registry

Working with the registry on 64 bit system. framework 2.0


How to get a list of subkeys in the HKLM\SOFTWARE in the 64 bit system?

P.S. If I use Registry.LocalMachine.OpenSubKey("SOFTWARE\\", false) then I get in HKLM\SOFTWARE\Wow6432Node

I can use the .NET Framework is not higher than 2.0


Solution

  • The answer seems quite involved, and probably too much code to put here on Stack Overflow.

    The summary is that you need to P/Invoke to access the native Windows API Calls for RegOpenKeyEx, and make sure to pass in the flag KEY_WOW64_64KEY to always access the 64bit registry. (KEY_WOW64_32KEY being the flag to always access the 32bit one)

    A partial solution has been posted on this blog entry.

    For anyone that can run .NET 4.0, then you can use the new support for this: RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);