title: Using RegSetKeySecurity to avoid registry redirection
body: <p>In order to avoid registry redirection to Wow64 keys, how to translate the following code that uses <code>Microsoft.Win32</code> APIs </p>
  
  <pre><code>public void SetKeyAccessControl(
              RegistryKey rootKey, string subKeyName, string identity, 
              RegistryRights rights, InheritanceFlags inheritanceFlags,
              PropagationFlags propagationFlags, AccessControlType accessType)
  {
     using (RegistryKey regKey = rootKey.OpenSubKey(subKeyName, true))
     {
         RegistrySecurity acl = new RegistrySecurity();
         RegistryAccessRule rule = new RegistryAccessRule(identity, rights, inheritanceFlags, propagationFlags, accessType);
         acl.AddAccessRule(rule);
  
         regKey.SetAccessControl(acl);
     }            
  }
  </code></pre>
  
  <p>into using advapi32 RegSetKeySecurity API</p>
  
  <pre><code>[DllImport(@"advapi32.dll", EntryPoint = "RegSetKeySecurity", SetLastError = true)]
  internal static extern int RegSetKeySecurity(IntPtr handle, uint securityInformation, IntPtr pSecurityDescriptor);
  </code></pre>