C# 将注册表项添加到 LocalMachine 失败 [英] C# add key to registry to LocalMachine fails

查看:32
本文介绍了C# 将注册表项添加到 LocalMachine 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向注册表中的 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 egedit.exe 中看到它.转到 C:WindowsSysWOW64 egedit.exe 在 x64 中查看它

Got it. Actually it was added, but with my x64 system I couldn't see it in simple C:Windows egedit.exe. Go to C:WindowsSysWOW64 egedit.exe to see it in x64

这篇关于C# 将注册表项添加到 LocalMachine 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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