0

为什么以下代码返回 NULL shellValue

        string shellValue;
        RegistryKey shellKey = Registry.LocalMachine;
        shellKey = shellKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
        shellValue = shellKey.GetValue("Shell") as string;

我确实有管理员权限。

4

1 回答 1

2

您实际上正在获取此子项“HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell”。这是因为某些键被 WOW64 重定向。检查以获取更多信息。

尝试以下操作:

string shellValue;
RegistryKey shellKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);;
shellKey = shellKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
shellValue = shellKey.GetValue("Shell") as string;
于 2013-09-21T12:42:24.030 回答