本文介绍了注册表项获取值返回NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么以下代码为 shellValue
返回NULL?
Why does the following code return NULL for shellValue
?
string shellValue;
RegistryKey shellKey = Registry.LocalMachine;
shellKey = shellKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
shellValue = shellKey.GetValue("Shell") as string;
我确实具有管理员权限.
I do have Administrator privileges.
推荐答案
您实际上正在获得此子项"HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon \ Shell".这是因为某些密钥是通过WOW64重定向的.检查此以获取更多信息.
You are actually getting this subkey "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell". This is because some keys are redirected by WOW64. Check this for more info.
请尝试以下操作:
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;
这篇关于注册表项获取值返回NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!