Exemplo n.º 1
0
 private RegistryKey OpenExplorerPoliciesKey()
 {
     RegistrySecurity RegistrySecurity = new RegistrySecurity();
     WindowsIdentity WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
     RegistryAccessRule AccessRule = new RegistryAccessRule(WindowsIdentity.Name, RegistryRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow);
     RegistrySecurity.AddAccessRule(AccessRule);
     RegistrySecurity.SetAccessRuleProtection(false, true);
     RegistryKey RegistryKey = Registry.LocalMachine.OpenSubKey(ExplorerPolitiesRegistryPath, true);
     RegistryKey.SetAccessControl(RegistrySecurity);
     return RegistryKey;
 }