简体   繁体   English

使用 vb 或 c# 将项目添加到注册表项并获得管理访问权限

[英]add item to key in registry with vb or c# AND get Administrative Access

I want add item to a key in registry and find "CreateSubKey" command but point is this command create sub key not item to a key.我想将项目添加到注册表中的一个键并找到“CreateSubKey”命令,但重点是此命令创建子键而不是键的项目。 for example path of "Computer\\HKEY_USERS.DEFAULT\\Control Panel\\International" has about 40 item and 3 sub key.例如“Computer\\HKEY_USERS.DEFAULT\\Control Panel\\International”的路径有大约 40 个项目和 3 个子键。 I want add item to "\\International" not sub key.我想将项目添加到“\\International”而不是子键。

another problem is that when I want add subkey to another users in "Computer\\HKEY_USERS" path ,I got error "cant access other user registry" .how could I handle that with code without login as admin in windows?另一个问题是,当我想向“Computer\\HKEY_USERS”路径中的其他用户添加子项时,出现错误“无法访问其他用户注册表”。如何在不以管理员身份登录 Windows 的情况下使用代码处理该问题?

LOOK AT PICTURE: enter image description here best regards.看图片:在此输入图片描述最好的问候。

Create the key you are interested in and then set the values :创建您感兴趣的密钥,然后设置值

RegistryKey rk = Registry.Users.CreateSubKey("DEFAULT\\Control Panel\\International");
rk.SetValue("a number", 42);
rk.SetValue("my string", "fiftythree");

You have to be elevated administrator to modify keys in roots other than CurrentUser.您必须被提升为管理员才能修改除 CurrentUser 之外的根目录中的密钥。 Normal users are not allowed to modify machine settings nor the settings of other users.不允许普通用户修改机器设置或其他用户的设置。

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

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