代码适用于CurrentUser但不适用于LocalMachine [英] Code Works For CurrentUser But Not For LocalMachine
本文介绍了代码适用于CurrentUser但不适用于LocalMachine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,盖尔和加尔斯,
我遇到了奇怪的问题.这是一段代码:
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE",True).OpenSubKey("Microsoft",True).OpenSubKey("Windows",True).OpenSubKey ("CurrentVersion",True).OpenSubKey("Explorer",True).OpenSubKey("MyComputer",True).OpenSubKey("NameSpace",True).CreateSubKey("{B4BFCC3A-DB2C-424C- B029-7FE99A87C641}")
如果存在 CurrentUser 在代码中可以正常工作.如果有 LocalMachine ,代码不起作用.
我已经仔细检查了注册表项是否存在.也不例外.有帮助吗?
解决方案
我相信您必须使用提升的特权(以管理员身份运行)运行应用程序,才能在注册表中对LocalMachine进行更改.
Hello Guy and Gals,
I am in weird problem. Here's a piece of code:
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE", True).OpenSubKey("Microsoft", True).OpenSubKey("Windows", True).OpenSubKey("CurrentVersion", True).OpenSubKey("Explorer", True).OpenSubKey("MyComputer", True).OpenSubKey("NameSpace", True).CreateSubKey("{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}")
If there's CurrentUser in the code, it works. If there's LocalMachine, the code doesn't work.
I have double checked that registry key exists. There's no exception even. Any help?
解决方案
I believe you have to run your application with elevated privileges (Run as Admin) to make changes to LocalMachine in the registry.
这篇关于代码适用于CurrentUser但不适用于LocalMachine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文