C#将注册表项添加到LocalMachine失败 [英] C# add key to registry to LocalMachine fails
问题描述
我正在尝试在注册表中的 LocalMachine
中添加密钥。我正在使用以下代码:
I'm trying to add a key to LocalMachine
in registry. I'm using this code:
System.Diagnostics.Debugger.Launch();
RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
RegistryKey newkey = key.CreateSubKey("1asdasds", RegistryKeyPermissionCheck.ReadWriteSubTree);
newkey.SetValue("ads", "ddsds");
newkey.Close();
我确实在管理员帐户上运行它。我事件以以管理员身份运行运行,但没有添加到注册表中:(。
当我将 LocalMachine
更改为 CurrentUser时
,实际上是将其添加到 CurrentUser
键中,但是如何强制将其添加到LocalMachine中?
I DO run it on Administrator account. I event run it with 'run as administrator", but nothing is added to registry :(.
When I change the LocalMachine
to CurrentUser
, actually it is added to CurrentUser
key. But how to force it to be added to LocalMachine?
推荐答案
确实得到了添加,但是在我的x64系统上,我无法在简单的C:\Windows\regedit.exe中看到它。 :\Windows\SysWOW64\regedit.exe在x64中查看
Got it. Actually it was added, but with my x64 system I couldn't see it in simple C:\Windows\regedit.exe. Go to C:\Windows\SysWOW64\regedit.exe to see it in x64
这篇关于C#将注册表项添加到LocalMachine失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!