We have an legacy application that accesses the registry. Because it is a 32bit application it accesses the registry in Windows 7 through Registry Virtualization when referencing HKEY_LOCAL_MACHINE\Software. My question is what setting(s) in Visual Studio do we need to modify to compile our applications where they access the registry "normally" without going through Registry Virtualization?
Why don't you use:
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\...");
return (string)key.GetValue("blah");
and add access to the registry in the customtrust.config file.
or doesn't that work in Windows 7?
If you read the Registry Virtualization page closely, you will notice that the virtualization is not limited to 64-bit Windows. It only states that only 32-bit processes will be virtualized. But the virtualization is done on both 32- and 64-bit Vista and later. So the question title and the x64 tag are a bit misleading.
To answer your question, the same page says this: "Registry virtualization is disabled for the following: ... Processes that have requestedExecutionLevel specified in their manifests."
So you can disable the virtualization by adding a manifest file to your executable that specifies its execution level. There is at least a Microsoft KB article for how to do it in Visual Studio 2005: http://support.microsoft.com/kb/944276.
The solution was to compile the legacy application to target x64. An application that is explicitly targeting x64 will not be subject to registry virtualization.