title: Reading and writing to x86 and x64 registry keys from the same application
body: <p>I am running my application compiled as x86, and it is running on 64 bit Windows. </p>
  
  <p>In order to fix a problem with ClickOnce file associations I want to read some CLSID values from the x86 view of the registry and then write them to the x64 view.</p>
  
  <p>To be clear, this means that from an x86 application I want to <em>simultaneously</em> read from the x86 registry view and then write to the x64 registry view. I want to take the values I find under <code>HKEY_CURRENT_USER\Software\Classes\CLSID\{my clsid}</code> and write them to <code>HKEY_CURRENT_USER\Software\Classes\Wow6432Node\CLSID\{my clsid}</code>.</p>
  
  <p>How should I do this? Using a <code>RegistryView</code> is producing unexpected results. For example, this <code>OpenSubKey</code> call returns null:</p>
  
  <pre><code>keyPath = @"Software\Classes\CLSID\" + clsid;
  var regularx86View = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32);
  var regularClassKey = regularx86View.OpenSubKey(keyPath, RegistryKeyPermissionCheck.ReadSubTree);
  </code></pre>
  
  <p>If I use <code>RegistryView.RegistryDefault</code> or <code>RegistryView.Registry64</code> instead it returns the key - but I would expect it to return null when using <code>Registry64</code> because that key doesn't exist in the x64 view and there should be no redirection taking place.</p>
  
  <p>Is using a <code>RegistryView</code> the appropriate thing to be doing, or should I be using the WinAPI directly?</p>