我正在尝试在注册表项上设置以下权限。但是当它尝试时我得到一个 NullReferenceException 错误。作为一个新手,这就是凝灰岩。加入权限(这总是让我感到困惑),我很困惑。有人能告诉我为什么我会得到这个吗?谢谢。
using System;
using Microsoft.Win32;
using System.Security.AccessControl;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
RegistrySecurity rs = new RegistrySecurity();
string user = "Everyone";
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Wow6432Node\123Test", true);
rs.AddAccessRule(new RegistryAccessRule(user,
RegistryRights.FullControl | RegistryRights.TakeOwnership,
InheritanceFlags.ContainerInherit,
PropagationFlags.None,
AccessControlType.Allow));
rk.SetAccessControl(rs);
}
}
}