Why does my 32-bit application not access the 32-bit registry hive?
c#
Solution
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):
On 64-bit Windows, portions of the registry entries are stored separately for 32-bit application and 64-bit applications and mapped into separate logical registry views using the registry redirector and registry reflection, because the 64-bit version of an application may use different registry keys and values than the 32-bit version. There are also shared registry keys that are not redirected or reflected.
Problem
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.