<p>I was making the following call:</p>

<pre><code>result = RegOpenKeyEx(key, s, 0, KEY_READ, &amp;key);
</code></pre>

<p>(C++, Visual Studio 5, Vista 64bit).</p>

<p>It is failing with error code 2 ("File not found") even though "<code>regedit</code>" shows that the key exists.  This code has always worked on 32bit XP.  Why is it "file not found" when it clearly is there?</p>

I discovered that I could solve my problem using the flag:
```
KEY_WOW64_64KEY
```
, as in:
```
```
result = RegOpenKeyEx(key, s, 0, KEY_READ|KEY_WOW64_64KEY, &key);
```
```
For a full explanation:
32-bit and 64-bit Application Data in the Registry