1

有人可以为我解释这个奇怪的结果吗?

在 linqPad 中得到以下代码

Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft").Dump();
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\Microsoft").Dump();

在进程监视器中查看时,它看起来像这样:

RegQueryKey    HKU\S-1-5-21-...   
RegOpenKey     HKU\S-1-5-21-...\Software\Microsoft   
RegSetInfoKey  HKU\S-1-5-21-...\Software\Microsoft   
RegQueryKey    HKU\S-1-5-21-...\Software\Microsoft   
RegQueryKey    HKU\S-1-5-21-...\Software\Microsoft   
RegQueryKey    HKLM   
RegOpenKey     HKLM\Software\Wow6432Node\Microsoft   
RegSetInfoKey  HKLM\SOFTWARE\Wow6432Node\Microsoft   
RegQueryKey    HKLM\SOFTWARE\Wow6432Node\Microsoft   
RegQueryKey    HKLM\SOFTWARE\Wow6432Node\Microsoft  

我的问题是:
为什么 Registry.CurrentUser 访问 64 位和 Registry.LocalMachine 32 位?

(还有,为什么 Registry.CurrentUser 访问HKU\S-..而不是HKCU

使用 Windows 7、64 位、.Net 3.5、LINQPad.exe *32

4

1 回答 1

2

如果您查看 MSDN文档,它会说 HKCU\Software\Classes 是通过 WOW64 重定向重定向的,但不是整个 HKCU\Software 键。

HKEY_CURRENT_USER           Shared          Shared
    SOFTWARE                Shared          Shared
        Classes             Shared          Redirected and reflected
            Appid           Shared          Redirected and reflected with one exception: the DllSurrogate and DllSurrogateExecutable registry values are not reflected if their value is an empty string.
            CLSID           Redirected      Redirected and reflected
            DirectShow      Redirected      Redirected and reflected
            Interface       Redirected      Redirected and reflected
            Media Type      Redirected      Redirected and reflected
            MediaFoundation Redirected      Redirected and reflected
于 2012-12-11T14:46:50.770 回答