Reading the registry and Wow6432Node key

后端 未结 4 1686
天涯浪人
天涯浪人 2020-11-29 00:02

I have some code that reads the registry and looks for a value in HKEY_LOCAL_MACHINE\\Software\\App\\ but when running on 64-bit versions of Windows the value i

4条回答
  •  醉话见心
    2020-11-29 00:26

    On an x64 machine, here is an example of how to access the 32-bit view of the registry:

    using (var view32 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser,
                                                RegistryView.Registry32))
    {
      using (var clsid32 = view32.OpenSubKey(@"Software\Classes\CLSID\", false))
      {
        // actually accessing Wow6432Node 
      }
    }
    

    ... as compared to...

    using (var view64 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser,
                                                RegistryView.Registry64))
    {
      using (var clsid64 = view64.OpenSubKey(@"Software\Classes\CLSID\", true))
      {
        ....
      }
    }
    

提交回复
热议问题