title: Reading 64bit Registry from a 32bit application
body: <p>I have a c# unit test project that is compiled for AnyCPU. Our build server is a 64bit machine, and has a 64bit SQL Express instance installed.</p>
  <p>The test project uses code similar to the following to identify the path to the .MDF files:</p>
  <pre><code>private string GetExpressPath()
  {
      RegistryKey sqlServerKey = Registry.LocalMachine.OpenSubKey( @&quot;SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL&quot; );
      string sqlExpressKeyName = (string) sqlServerKey.GetValue( &quot;SQLEXPRESS&quot; );
      RegistryKey sqlInstanceSetupKey = sqlServerKey.OpenSubKey( sqlExpressKeyName + @&quot;\Setup&quot; );
      return sqlInstanceSetupKey.GetValue( &quot;SQLDataRoot&quot; ).ToString();
  }
  </code></pre>
  <p>This code works fine on our 32bit workstations, and did work ok on the build server until I recently enabled code coverage analysis with NCover. Because NCover uses a 32bit COM component, the test runner (Gallio) runs as a 32bit process.</p>
  <p>Checking the registry, there is no &quot;Instance Names&quot; key under</p>
  <blockquote>
  <p>HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server</p>
  </blockquote>
  <p>Is there a way for an application running in 32bit mode to access the registry outside  Wow6432Node?</p>