I have a C# application that calls:
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\MyApp")
It is set to target x86, and when I run it I can see from Task Manager that it is a 32-bit process. However that line of code is strangely going to the 64-bit hive at HKCU\Software\MyApp, instead of the 32-bit hive at HKCU\Software\Wow6432Node\MyApp. Any ideas?
I also started two instances of Powershell, one 32-bit and one 64-bit, and ran the below but both return the values at the 64-bit hive too.
get-itemproperty -Path Registry::HKEY_CURRENT_USER\Software\MyApp
Any ideas what might have gone wrong here? I have triple-checked that the registry settings at the 32 and 64 bit hives are different from regedit too.
Because you are accessing a key (HKCU\Software) that is shared, not redirected. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms724072(v=vs.85).aspx and (more specifically) http://msdn.microsoft.com/en-us/library/windows/desktop/aa384253(v=vs.85).aspx
From the first link (emphasis mine):