我添加了一个注册表项,但是无法以编程方式找到它 [英] I added a registry key, but I cannot find it programmatically

查看:149
本文介绍了我添加了一个注册表项,但是无法以编程方式找到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我使用RegEdit将以下内容添加到工作站上的注册表中:

So I used RegEdit to add the following to the registry on my workstation:

HKLM \ Software \ Foo \ Bar

HKLM\Software\Foo\Bar

Bar有k/v对的"wtf"/"idk".我通过关闭regedit并重新打开来验证这些更改是否生效".嘿,他们还在那里!胀.

Bar has a k/v pair of "wtf"/"idk". I verified that these changes "took" by closing regedit and re-opening it. Hey, they're still there! Swell.

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Foo\Bar");

if (key != null)
{
    var = key.GetValue("wtf").ToString();
}

问题是,键为空.

何时. .

Registry.LocalMachine.OpenSubKey("Software").GetSubKeyNames()

被称为Foo不会出现在众多SubKeyName中.

Is called, Foo doesn't show up amongst the however many SubKeyNames.

因此,我显然很想念一些愚蠢的东西.我到底想念什么?

So, I am obviously missing something stupid. What specifically am I missing?

推荐答案

如果您在64位版本的Windows上运行32位进程,则32位进程(您的测试应用程序)并不总是能够看到您的密钥使用64位regedit创建的.

If you are running a 32 bit process on a 64 bit version of Windows the 32 bit process (your test application) is not always able to see the keys you created using 64 bit regedit.

尝试以64位运行您的应用程序,或使用regedit通过路径HKLM\SOFTWARE\Wow6432Node\Foo\Bar打开密钥.

Try running your application as 64 bit or use regedit to open the key using the path HKLM\SOFTWARE\Wow6432Node\Foo\Bar.

您可以阅读有关32位和MSDN上注册表中的64位应用程序数据.

这篇关于我添加了一个注册表项,但是无法以编程方式找到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆