I have a normal 32 bit application which does the following:
HKEY hKey;
int nCount = 0;
DWORD dwLen;
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID\\{<<UUID>>}", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
{
printf("problem\n");
return nCount ;
}
if (RegQueryValueEx(hKey, "u", NULL, NULL, (LPBYTE) &nCount , &dwLen) != ERROR_SUCCESS)
{
printf("problem2\n");
}
return nCount ;
I'm using Visual C++ 6.0 and compile it for normal 32 bit. When I run it on normal 32 bit Windows XP everything runs as it should. When I run it in debug mode under Windows XP x64 everything is stored under [HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{<<UUID>>}] as it's suppose to and the above code reads the values correctly.
However when I recompile the same code under release mode nothing works anymore. It won't read the values anymore and it'll print out "problem2" on console.
I cannot explain this behavior as it is very weird.
Why would a 32 bit program suddenly stop working when compiled in release mode under x64
I all I know is that the application still works as it should under release mode with 32 bit XP.
Thanks in advance.
-- Henrik

Weird registry behavior with Win64 (AMD64)
Mesia
Ok case closed.
It turned out that dwLen was uninitialized. Under normal circumstances debug mode would fill the variable with something like 0xCC values whereas release mode would not.
-- Henrik