How to open a WOW64 registry key from a 64-bit .NET application

后端 未结 4 854
萌比男神i
萌比男神i 2020-11-29 04:54

My .NET application (any-CPU) needs to read a registry value created by a 32-bit program. On 64-bit Windows this goes under the Wow6432Node key in the registry. I have read

4条回答
  •  暖寄归人
    2020-11-29 05:10

    If you can change the target .Net version to v4, then you can use the new OpenBaseKey function e.g.

    RegistryKey registryKey;
    if (Environment.Is64BitOperatingSystem == true)
    {
        registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
    }
    else
    {
        registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
    }
    

提交回复
热议问题