如何将新权限(ACL)分配给现有registry项,而不从父项inheritance权限

可以使用RegistryKey.SetAccessControl(new RegistrySecurity(...))设置新权限。 但在此之后, inheritance is turned on

有没有一种方法来分配新的权利,而不继续打开?

整个代码:

 void test { SecurityIdentifier sidAccUser = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null); NTAccount ntAccUser = sidAccUser.Translate(typeof(NTAccount)) as NTAccount; RegistryAccessRule regAcRule = new RegistryAccessRule( ntAccUser , RegistryRights.FullControl , InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit , PropagationFlags.None , AccessControlType.Allow); RegistrySecurity regSecurity = new RegistrySecurity(); regSecurity.AddAccessRule(regAcRule); RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"ZZTEST", true); // after that the inheritance is turned on regKey.SetAccessControl(regSecurity); } 

我发现这个解决scheme,但不想使用COM服务器: 设置权限和阻塞C#与SetACL的inheritance

Solutions Collecting From Web of "如何将新权限(ACL)分配给现有registry项,而不从父项inheritance权限"