Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 226
StudentX Avatar asked Feb 27 '13 12:02

StudentX


People also ask

What is _WIN32_WINNT?

The preprocessor macros WINVER and _WIN32_WINNT specify the minimum operating system version your code supports. Visual Studio and the Microsoft C++ compiler support targeting Windows 7 SP1 and later.

How do you define Winver?

Winver is a command that displays the version of Windows that is running, the build number and what service packs are installed: Click Start – RUN , type “winver” and press enter. If RUN is not available, the PC is running Windows 7 or later. Type "winver" in the "search programs and files" textbox.


2 Answers

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

like image 109
john.pavan Avatar answered Oct 07 '22 19:10

john.pavan


  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++.
like image 31
Aniket Inge Avatar answered Oct 07 '22 20:10

Aniket Inge