To modify permissions for a registry key, use the erload:Microsoft.Win32.RegistryKey.GetAccessControl method to obtain a System.Security.AccessControl.RegistrySecurity object representing the existing Windows access control security, modify that System.Security.AccessControl.RegistrySecurity object, and then use the RegistryKey.SetAccessControl(System.Security.AccessControl.RegistrySecurity) method to update security for the key.
The System.Security.AccessControl.RegistrySecurity object specified for registrySecurity replaces the existing security for the registry key. To add permissions for a new user, use the erload:Microsoft.Win32.RegistryKey.GetAccessControl method to obtain the existing access control security, and then modify it.