Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

What is the safe and proper way to read a registry key?

$
0
0

I tried running code that worked fine on Server 2003 before, to run on Server 2008.

DWORD result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MyPath\\MyKey", 0, KEY_READ, &key);

return 2.

I read up on redirection, virtualization, etc. etc. I thought the whole point was that there would be no effect on existing code? I created a key using regedit and regedit32. In niether case would the error go away.

So , I googled some more. I added the KEY_WOW64_64KEY and it works.

Ok, great. So now, what about those machines that don't have Wow64? What if I install it on Server 2003 again?

What is the proper way to read a registry key that is safe for 32bit AND 64 bit builds, on a 32 bit AND 64 bit machine?



Viewing all articles
Browse latest Browse all 15302

Trending Articles