可写注册表权限
本文关键字:权限 注册表 | 更新日期: 2023-09-27 18:08:09
RegistrySecurity rs = new RegistrySecurity();
RegistryKey rk =
RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).
OpenSubKey("SOFTWARE''MyApplication", true);
rs.AddAccessRule(new RegistryAccessRule("Everyone",
RegistryRights.WriteKey | RegistryRights.ReadKey | RegistryRights.Delete,
InheritanceFlags.None,
PropagationFlags.None,
AccessControlType.Allow));
我正试图从注册表中为SOFTWARE下的特定文件夹赋予所有系统用户可写权限。但是我不能用c#代码做到这一点。
//完整解决方案:
RegistrySecurity rs = new RegistrySecurity();
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE'ASUS", true);
rs.AddAccessRule(new RegistryAccessRule("Everyone", RegistryRights.WriteKey | RegistryRights.ReadKey, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Deny));
if(rk != null)
{
rk.SetAccessControl(rs);
}