Thank you for your suggestion, I'll take a look at serialization.
Additional, this is my code
1 | RegistrySecurity rs = new RegistrySecurity(); |
2 | RegistryKey rk = Registry.ClassesRoot.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl); // Opens the key again with full control. |
3 | rs.SetOwner( new NTAccount( "newAdmin" )); // Set the securitys owner to newAdmin |
4 | rs.SetAccessRuleProtection( true , false ); |
5 | rk.SetAccessControl(rs); // Set the key with the changed permission so Administrator is now owner. |