C++ SDKDDKVer.h 有什么用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10539391/
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 SDKDDKVer.h for?
提问by jokoon
All project created with MSVC have stdafx, which is precompiled headers, which I know what they are but what about targetver.h ? It includes SDKDDKVer.h, and I can't find what is that header about.
所有用 MSVC 创建的项目都有 stdafx,它是预编译的头文件,我知道它们是什么,但是 targetver.h 呢?它包括 SDKDDKVer.h,我找不到那个标题是什么。
What is this for ?
这个是来做什么的 ?
回答by Andy
targetver.h
and SDKDDKVer.h
are used to control what functions, constants, etc. are included into your code from the Windows headers, based on the OS that you want your program to support. I believe that targetver.h
sets defaults to using the latest version of Windows unless the defines are specified elsewhere.
targetver.h
并SDKDDKVer.h
用于根据您希望程序支持的操作系统来控制从 Windows 头文件中将哪些函数、常量等包含到您的代码中。我相信targetver.h
除非在其他地方指定了定义,否则设置默认使用最新版本的 Windows。
SDKDDKVer.h
is the header file that actually defines the #defines
that represent each version of Windows, IE, etc.
SDKDDKVer.h
是实际定义#defines
代表每个版本的 Windows、IE 等的头文件。
回答by Pressacco
Line 193 of the SDKDDKVer.h
(in SDK 8.1) states:
SDKDDKVer.h
(在 SDK 8.1 中)的第 193 行指出:
"if versions aren't already defined, default to most current"
“如果尚未定义版本,则默认为最新版本”
This comment is specifically referring to the _WIN32_WINNT
and NTDDI_VERSION
macros.
此注释特指_WIN32_WINNT
和NTDDI_VERSION
宏。
So..
所以..
SDKDDKVer.h
applies default values unless the macros have already been defined- the following code can be used to explicitly define the macros
#define _WIN32_WINNT 0x0601
#define NTDDI_VERSION 0x06010000
- Interestingly enough, the
SDKDDKVer.h
header file has 'constant' values defined for all of the SDK versions. For example:#define _WIN32_WINNT_WINXP 0x0501
#define _WIN32_WINNT_WIN7 0x0601
#define _WIN32_WINNT_WIN8 0x0602
- One convention is to define
_WIN32_WINNT
andNTDDI_VERSION
in a header file calledTargetVer.h
, which you would reference in your pre-compiled headerStdAfx.h
.
SDKDDKVer.h
除非宏已经定义,否则应用默认值- 以下代码可用于显式定义宏
#define _WIN32_WINNT 0x0601
#define NTDDI_VERSION 0x06010000
- 有趣的是,
SDKDDKVer.h
头文件为所有 SDK 版本定义了“常量”值。例如:#define _WIN32_WINNT_WINXP 0x0501
#define _WIN32_WINNT_WIN7 0x0601
#define _WIN32_WINNT_WIN8 0x0602
- 一种约定是在名为 的头文件中定义
_WIN32_WINNT
和,您将在预编译NTDDI_VERSION
的头文件中TargetVer.h
引用该文件StdAfx.h
。