写注册表,带权限控制
 public void Write()
        {
            RegistrySecurity rsy = new RegistrySecurity();
RegistryAccessRule rar = new RegistryAccessRule(Environment.UserDomainName +
"\\" + Environment.UserName, RegistryRights.ReadKey | RegistryRights.WriteKey |
RegistryRights.Delete, InheritanceFlags.ContainerInherit, PropagationFlags.None,
AccessControlType.Allow);
rsy.AddAccessRule(rar);
Microsoft.Win32.RegistryKey rootKey = Microsoft.Win32.Registry.LocalMachine;//本地计算机数据的配置
            Microsoft.Win32.RegistryKey runKey = rootKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", RegistryKeyPermissionCheck.ReadWriteSubTree, rsy);
        }
                    
                
                
            
        
浙公网安备 33010602011771号