C++ 什么是 _WIN32_WINNT,它是如何工作的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15111799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is _WIN32_WINNT and how does it work?
提问by StudentX
EDIT 2:Ok so I changed to Orwell DevC++ which contains the "winnt.h" that contains #define KEY_WOW64_64KEY 0x0100but it still is not working. (Refer to EDIT 1:)
编辑 2:好的,所以我改为 Orwell DevC++,其中包含包含#define KEY_WOW64_64KEY 0x0100的“winnt.h”,但它仍然无法正常工作。(请参阅编辑 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:
编辑 1:我查看了随 CodeBlock 和 DevC++ 一起出现的“winnt.h”,而 DevC++ 缺少以下几行:
#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.
而把上面的代码放到DevC++的wint.h里面是不行的。
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 : thisand this
原帖:我有一个 32 位应用程序(在 DevC++ 和 Windows 7 64 位上开发)它读取 64 位应用程序的注册表作为其任务之一,所以我尝试在 RegOpenKeyEx 中使用“KEY_WOW64_64KEY”标志,并且发现很少有关于如何使用的帖子它与 _WIN32_WINNT :这个和这个
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.
当我在 CodeBlock 项目(一个测试项目)中使用它时,它就像魅力一样,但相同的代码不适用于 DevC++,我现在无法将它移植到 codeblock,因为 codeblock 存在其他问题。
How do I make it work with DevC++ ?
我如何使它与 DevC++ 一起工作?
Thanks
谢谢
回答by john.pavan
It defines the version of the windows header files to use. It must be declared before you #include <Windows.h>
.
它定义了要使用的 Windows 头文件的版本。它必须在你面前声明#include <Windows.h>
。
There are a few other similar variables you should probably set if you're going to modify it:
如果您要修改它,您可能应该设置其他一些类似的变量:
回答by Aniket Inge
_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.
_WIN32_WINNT
是一个预处理器令牌,它被替换为(0x0601)
where_WIN32_WINNT
is used。预处理器只扫描整个文件,并替换_WIN32_WINNT
有(0x0601)
到处发现。
Chances are, there could be ifdef
preprocessor guards that will enable/disable a preprocessor constant. Like:
很有可能,可能会有ifdef
预处理器保护来启用/禁用预处理器常量。喜欢:
#ifdef _WIN32_WINNT
#define KEY32 32
#endif
There, KEY32
will only be defined IF_WIN32_WINNT
is defined.
那里,KEY32
只会被定义IF_WIN32_WINNT
被定义。
- It already works with DevC++.
- 它已经适用于 DevC++。