title: Create registry key programmatically
body: <p>I'm working on a C# project and I'm very confused about the creation of a registry key.</p>
  
  <p>I have a Wix Installer. And the and of the setup File, i'm calling a custom action to create sub key (I'v try with the wix feature but it didn't work).</p>
  
  <p>My custom action is :</p>
  
  <pre><code>RegistryKey Nkey = Registry.LocalMachine;
  RegistryKey valkey = Nkey.OpenSubKey(Manager.REGKEY, true); //=&gt; REGKEY = "Software\\MyService"
  if (valkey == null)
  {
      valkey = Nkey.CreateSubKey(GestionCertificats.REGKEY);
  }
  valkey.Close();
  
  Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\services\eventlog\Application\MyService");
  </code></pre>
  
  <p>After install, I can see the second key but no the first one. I'm not sure to right understand the operation of the keys. I'm working on a windows 7 64 bit, I'm compiling with "Any CPU" but my application seems to be in x86.</p>
  
  <p>I've try to debug the action. value <code>valkey</code> is not null, but I didn't see the key with regedit. By forcing the <code>CreateSubKey</code> I still have no key.</p>
  
  <p>I don't know what to do, I need help.</p>