C#无法读取键值名称

C#无法读取键值名称,c#,registry,C#,Registry,我正在尝试读取C中注册表上的所有子项# 它对本机子键很有效,但当我创建自己的键时,我无法读取它 string all = "-start" + Environment.NewLine; string registryKey2 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\AnimateMinMax"; RegistryKey key2 = Registry.LocalMachine.OpenSubKey(

我正在尝试读取C中注册表上的所有子项# 它对本机子键很有效,但当我创建自己的键时,我无法读取它

string all = "-start" + Environment.NewLine;
string registryKey2 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\AnimateMinMax";
RegistryKey key2 = Registry.LocalMachine.OpenSubKey(registryKey2, true);

foreach (string valueName in key2.GetValueNames())
{
    all += valueName + Environment.NewLine;
}
all += "-End" + Environment.NewLine;
MessageBox.Show(all);

缺少“测试”Dword密钥

你有什么建议吗


向您致意

您看到的注册表项部分不正确。应用程序编译为32位,但操作系统为64位。 在这种情况下,Windows会自动重定向到注册表的
WOW6432Node
,其中该项不存在

解决方案:

1) 在项目设置中,将目标CPU更改为x64

2) 使用
RegistryView.Registry64
标志打开64位注册表视图

var localMachine64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
var key2 = localMachine64.OpenSubKey(registryKey2, true);
// rest of the code

你的应用程序是32位还是64位?还有,你的操作系统?32位还是64位?谢谢@EylM我在构建项目中取消了“32位优先”复选框,现在一切正常:)再次感谢!