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

  • Thread starter Thread starter Christopher Pisz
  • Start date Start date
C

Christopher Pisz

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

DWORD result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Siemens\\Mobility\\TS\\MoCo\\FieldCommunications", 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 dont 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?

Continue reading...
 
Back
Top