What is _WIN32_WINNT and how does it work?

不打扰是莪最后的温柔 提交于 2020-01-02 04:35:09

问题


EDIT 2: Ok so I changed to Orwell DevC++ which contains the "winnt.h" that contains #define KEY_WOW64_64KEY 0x0100 but it still is not working. (Refer to EDIT 1:)

EDIT 1: I looked into the "winnt.h" which came along the CodeBlock and DevC++ and the DevC++'s is missing the following lines:

#if (_WIN32_WINNT >= 0x0502)
#define KEY_WOW64_64KEY 0x0100
#define KEY_WOW64_32KEY 0x0200
#endif

And putting the above code in the wint.h of DevC++ doesn't work.


Original Post: I have a 32bit application (developing in DevC++ and Windows 7 64bit) which reads a 64bit app's registry as one of its task, so I am trying to use "KEY_WOW64_64KEY" flag in RegOpenKeyEx, and found few posts regarding how to use it with _WIN32_WINNT : this and this

It worked like charm when I used it in a CodeBlock Project(a test project) but the same code is not working with DevC++, I can't port it to codeblock now since codeblock presents other problems.

How do I make it work with DevC++ ?

Thanks


回答1:


It defines the version of the windows header files to use. It must be declared before you #include <Windows.h>.

There are a few other similar variables you should probably set if you're going to modify it:

MSDN Using Windows Headers




回答2:


  1. _WIN32_WINNT is a preprocessor token, which is replaced by (0x0601) wherever _WIN32_WINNT is used. The preprocessor just scans the whole file and replaces _WIN32_WINNT with (0x0601) everywhere it is found.

Chances are, there could be ifdef preprocessor guards that will enable/disable a preprocessor constant. Like:

#ifdef _WIN32_WINNT
#define KEY32 32
#endif

There, KEY32 will only be defined IF _WIN32_WINNT is defined.

  1. It already works with DevC++.


来源:https://stackoverflow.com/questions/15111799/what-is-win32-winnt-and-how-does-it-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!