为什么以下代码为shellValue
返回NULL?
string shellValue;
RegistryKey shellKey = Registry.LocalMachine;
shellKey = shellKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
shellValue = shellKey.GetValue("Shell") as string;
我有管理员权限。
答案 0 :(得分:2)
您实际上正在获取此子项“HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon \ Shell”。这是因为某些键被WOW64重定向。查看this了解详情。
尝试以下方法:
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;