Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is RegOpenKeyEx() returning error code 2 on Vista 64bit?

I was making the following call:

result = RegOpenKeyEx(key, s, 0, KEY_READ, &key); 

(C++, Visual Studio 5, Vista 64bit).

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

like image 767
Tim Cooper Avatar asked Oct 31 '08 00:10

Tim Cooper


1 Answers

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

like image 134
Tim Cooper Avatar answered Sep 19 '22 12:09

Tim Cooper