C++ 什么是WINVER?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1439752/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 19:58:29  来源:igfitidea点击:

What is WINVER?

c++windowsheaderheader-files

提问by aajkaltak

I was looking at some code and they had this line: #define WINVER 0x0501in stdafx.hfile? Why do you need to define WINVER? How does it affect your code? Can someone please explain?

我正在查看一些代码,他们有这一行:#define WINVER 0x0501stdafx.h文件中?为什么需要定义WINVER?它如何影响您的代码?有人可以解释一下吗?

采纳答案by Reed Copsey

WINVER determines the minimum platform SDK required to build your application, which in turn will determine at compile time which routines are found by the headers.

WINVER 确定构建应用程序所需的最低平台 SDK,这反过来将在编译时确定头文件找到哪些例程。

You can use this to verify, at compile time, that your application will work on Windows 2000 (0x0500), for example, or on Windows XP (0x0501).

您可以在编译时使用它来验证您的应用程序是否可以在 Windows 2000 (0x0500) 上运行,例如,或在 Windows XP (0x0501) 上运行。

MSDN's page on Modifying WINVER and _WIN32_WINNTgoes into this in more detail.

MSDN 关于修改 WINVER 和 _WIN32_WINNT的页面对此进行了更详细的介绍。

回答by David Thornley

WINVER defines the minimum Windows system the program can run on. There's a more detailed explanation at MSDN. What #define WINVER 0x0501means is that the program requires Windows XP or Server 2003 to run, and that it therefore can use Windows functionality up through that release.

WINVER 定义了程序可以运行的最小 Windows 系统。MSDN上有更详细的解释。这#define WINVER 0x0501意味着该程序需要 Windows XP 或 Server 2003 才能运行,因此它可以在该版本之前使用 Windows 功能。

回答by Kirill V. Lyadvinsky

By defining WINVERmacro you unhide a set of functions specific to a certain Windows version. For instance, if you define it as #define WINVER 0x0502you will not able to use TaskDialogwhich is available only in Windows Vista. For more detail you could read the Using the Windows Headersarticle in MSDN.

通过定义WINVER宏,您可以取消隐藏特定于某个 Windows 版本的一组功能。例如,如果您将其定义为#define WINVER 0x0502您将无法使用仅在 Windows Vista 中可用的TaskDialog。有关更多详细信息,您可以阅读MSDN 中的Using the Windows Headers文章。

回答by Graeme Perrow

WINVER means Windows Version. In a nutshell, if you're building for a particular version of Windows, some APIs are available that are not available on previous versions.

WINVER 表示 Windows 版本。简而言之,如果您正在为特定版本的 Windows 构建,则可以使用一些 API,而这些 API 在以前的版本中是不可用的。