简体   繁体   English

在.net应用程序的注册表中获得对local_machine \\ software的写访问权限

[英]Get write access to local_machine\software in the registry for .net application

I am trying to change the friendly name of a USB sound card. 我正在尝试更改USB声卡的友好名称。 I can don't it from windows as well as edit the registry location using regedit. 我不能从Windows以及使用regedit编辑注册表位置。 But I get an exception when I try to open the subkey for write access. 但是,当我尝试打开子项以进行写访问时却遇到了异常。

Is there any way to get around this. 有什么办法可以解决这个问题。 For now my work around is to build the correct registry import file and run that, but I would like it much better if it could be implemented in code. 现在,我的工作是构建正确的注册表导入文件并运行该文件,但是如果可以用代码实现,我希望它更好。

Are you running your c# application as an administrator? 您是否以管理员身份运行c#应用程序? Only a user with administrative rights has access to write to HKLM. 仅具有管理权限的用户有权写HKLM。

The way I got around this is to write a text file in the format that can be imported into the registry and just call that file using Process.Start("edit.reg") or what ever you named your file. 我解决这个问题的方法是编写一个可以导入注册表的格式的文本文件,然后使用Process.Start("edit.reg")或您命名的文件调用该文件。 Works for now, only need to do this once on installation, for now. 现在就可以使用,现在只需要在安装时执行一次即可。

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

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