HKLM\Software 下的 OpenSubKey 返回 null [英] OpenSubKey under HKLM\Software returning null

查看:49
本文介绍了HKLM\Software 下的 OpenSubKey 返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ADM");

注册表项存在于机器上.键始终为空.

The registry entry exists on the machine. key is always null.

我不认为这是一个安全问题.我以管理员身份运行.(我什至明确地在管理员模式下运行程序集).

I don't think that this is a security issue. I'm running as Administrator. (I've even explicitly ran the assembly under Administrator mode).

我使用的是在 Windows 7 64 位上运行的 Visual Studio 2010.

I'm using Visual Studio 2010 running on Windows 7 64bit.

推荐答案

问题是我运行的是 64 位,而我的应用程序被编译为 32 位.

The problem is that I'm running 64bit and my app is compiled as 32bit.

正在读取的密钥:

Microsoft.Win32.RegistryKey key = 
    Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE");

不是 HKLM\SOFTWARE 而是 HKLM\SOFTWARE\Wow6432Node\.将应用程序编译为 x64 可以解决问题.

Is not HKLM\SOFTWARE but instead HKLM\SOFTWARE\Wow6432Node\. Compiling the application as x64 solves the problem.

这篇关于HKLM\Software 下的 OpenSubKey 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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