简体   繁体   中英

What is _WIN32_WINNT and how does it work?

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

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

  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++.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM