C#在注册表本地计算机中创建值 [英] C# Create Values in Registry Local Machine
本文介绍了C#在注册表本地计算机中创建值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码对我不起作用:
The following code is not working for me:
public bool createRegistry()
{
if (!registryExists())
{
Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\xelo\\");
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\xelo").SetValue("hostname", (string)hostname, Microsoft.Win32.RegistryValueKind.String);
return true;
}
else
{
return updateRegistry();
}
}
例外:
System.UnauthorizedAccessException |无法写入注册表键"
System.UnauthorizedAccessException | "Cannot write to the registry key"
推荐答案
非管理员和非提升管理员用户无权修改HKEY_LOCAL_MACHINE密钥.以管理员身份运行程序.
Non-admin and unelevated admin users don't have rights to modify the HKEY_LOCAL_MACHINE key. Run the program 'as administrator'.
这篇关于C#在注册表本地计算机中创建值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文