Needed to define a user and registry security to a key change....
public static bool AddRegKey(string keyName, string valueName)
{
try
{
string user = Environment.UserDomainName + "\\" + Environment.UserName;
RegistrySecurity rs = new RegistrySecurity();
rs.AddAccessRule(new RegistryAccessRule(user,
RegistryRights.ReadKey |
RegistryRights.Delete |
RegistryRights.WriteKey |
RegistryRights.ChangePermissions,
InheritanceFlags.None,
PropagationFlags.None,
AccessControlType.Allow));
RegistryKey key = Registry.CurrentUser.OpenSubKey(sDRCRegKey,true);
key.SetAccessControl(rs);
key.SetValue(keyName, valueName);
return true;
}
catch
{
return false;
}
}
No comments:
Post a Comment