What is 32 & 64 bit c++ code?

后端 未结 1 1845
醉话见心
醉话见心 2021-01-28 05:48

I\'m trying to get a value from a registry key, and the final program has to work on both 32 & 64 bit machines.

The code so far is:

   HKEY hKey; 
          


        
相关标签:
1条回答
  • 2021-01-28 06:05

    On 64 bit Windows there are two registry views, the 32 bit view and the 64 bit view. This is described over on MSDN in the topic titled Accessing an Alternate Registry View.

    By default a 32 bit process will read from the 32 bit view, and a 64 bit process will read from the 64 bit view. If you wish to read from a particular view, irrespective of the architecture of the process you need to supply one of the following flags: KEY_WOW64_64KEY or KEY_WOW64_32KEY.

    So, if the data that you need is in the 32 bit view, pass KEY_WOW64_32KEY. If the data is in the 64 bit view pass KEY_WOW64_64KEY. If the data could be in either key, check twice, once passing KEY_WOW64_32KEY and once again passing KEY_WOW64_64KEY.

    0 讨论(0)
提交回复
热议问题