读取注册表项 [英] Read registry key

查看:35
本文介绍了读取注册表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做错了吗?我没有得到任何回报...

Am I doing something wrong? I get no value back...

Imports Microsoft.Win32
...
Dim s As String = ""
Dim reg As RegistryKey

reg =Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
s = reg.GetValue("RtHDVCpl", "")
MsgBox(s)
reg.Close()

推荐答案

如果您没有发现异常,那么您可以放心地假设该值不存在或使用空字符串作为其值.

If you get no exception then you can safely assume that the value does not exist or has an empty string as its value.

如果您确定该值确实存在,那么下一个解释是您的机器运行的是 64 位操作系统.为 32 位进程虚拟化注册表的位置.他们将从 HKLM\Software\Wow6432Node 读取值.并且您正在运行 VS2010,它会强制项目默认以 32 位运行.项目 + 属性,编译选项卡,向下滚动,高级编译选项.将目标 CPU 更改为 AnyCPU.在 Express 版 afaik 中不可用,您必须手动编辑 .vbproj 文件.

If you are sure that the value in fact exists then the next explanation is that your machine runs a 64-bit operating system. Where the registry is virtualized for 32-bit processes. They will read values from HKLM\Software\Wow6432Node. And that you're running VS2010, it forces projects to run in 32-bit by default. Project + Properties, Compile tab, scroll down, Advanced Compile Options. Change Target CPU to AnyCPU. Not available in the Express edition afaik, you'd have to edit the .vbproj file by hand.

这篇关于读取注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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