简体   繁体   English

C#注册表无法删除MachineGuid访问被拒绝

[英]C# registry Can't delete MachineGuid access denied

Here's my code: 这是我的代码:

RegistryKey reg = Registry.LocalMachine;
var HKLM = reg.OpenSubKey(@"Software\\Microsoft\\Cryptography");
HKLM.DeleteValue("MachineGuid");

Problem: Even when I run it as an administrator; 问题:即使我以管理员身份运行它; it will just give me an error that saying: 这只会给我一个错误,说:

Cannot write to the registry key. 无法写入注册表项。

I can't delete anything in the local machine folder. 我无法删除本地计算机文件夹中的任何内容。

如果要进行写访问,则需要将RegistryKey指定为可写的。

Registry.LocalMachine.OpenSubKey(@"Software\\Microsoft\\Cryptography",true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM