gpt4 book ai didi

C# 在注册表本地计算机中创建值

转载 作者:IT王子 更新时间:2023-10-29 04:33:29 25 4
gpt4 key购买 nike

以下代码对我不起作用:

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();
}
}

异常(exception):

System.UnauthorizedAccessException | "Cannot write to the registry key"

最佳答案

非管理员和未提升权限的管理员用户无权修改 HKEY_LOCAL_MACHINE 键。 “以管理员身份”运行程序。

关于C# 在注册表本地计算机中创建值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2723413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com