从注册表中删除文件夹 - 权限问题 [英] Delete Folder from Registry - Permission Issues

查看:54
本文介绍了从注册表中删除文件夹 - 权限问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从注册表中删除一个文件夹.假设我想删除文件夹

I am trying to delete one folder from registry. Let's say I want to delete the folder

Software\TeamViewer

我已经写了代码,但它给出了一个例外你不能写".我猜它的 Permission & 有某种问题.访问权限.

I have written code but it is gives an exception "you can't write". I guess its some kind of problem with the Permission & access rights.

string keyapath = @"Software\TeamViewer";
RegistryKey regKeyAppRoot = Registry.CurrentUser.OpenSubKey(keyapath);
regKeyAppRoot.DeleteSubKeyTree(keyapath);

如何授权我的软件从注册表中删除文件夹?

How do I give permission to my software to delete folders from registry?

我有我的系统的管理员权限.我还需要通过我的代码专门为应用程序分配权限吗?

I have admin rights of my system. Do I still need to exclusively assign rights to the application through my code?

推荐答案

带一个参数的OpenSubKey 方法打开密钥进行读取.使用 OpenSubKey 方法的其他变体:

The OpenSubKey method with one parameter opens the key for reading. Use other variant of OpenSubKey method:

OpenSubKey(String, Boolean)-- 为第二个参数传递 true 以打开具有通用写访问权限的密钥

OpenSubKey(String, Boolean) -- Pass true for a second parameter to open the key with generic write access

OpenSubKey(String, RegistryKeyPermissionCheck)-- 允许对子键的权限破解进行一些精确的控制

OpenSubKey(String, RegistryKeyPermissionCheck) -- Allows some precise control over the permission chacking for subkeys

OpenSubKey(String, RegistryKeyPermissionCheck, RegistryRights)-- 同上,但您可以准确指定所需的权限.

OpenSubKey(String, RegistryKeyPermissionCheck, RegistryRights) -- As above, but you can exactly specify needed rights.

有关详细信息,请参阅 MSDN.

See MSDN for details.

这篇关于从注册表中删除文件夹 - 权限问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆