what is SDKDDKVer.h for?

2020-01-31 00:54发布

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.

What is this for ?

2条回答
三岁会撩人
2楼-- · 2020-01-31 01:34

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.

SDKDDKVer.h is the header file that actually defines the #defines that represent each version of Windows, IE, etc.

查看更多
我只想做你的唯一
3楼-- · 2020-01-31 01:41

Line 193 of the SDKDDKVer.h (in SDK 8.1) states:

"if versions aren't already defined, default to most current"

This comment is specifically referring to the _WIN32_WINNT and NTDDI_VERSION macros.

So..

  1. SDKDDKVer.h applies default values unless the macros have already been defined
  2. the following code can be used to explicitly define the macros
    • #define _WIN32_WINNT 0x0601
    • #define NTDDI_VERSION 0x06010000
  3. 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
  4. One convention is to define _WIN32_WINNT and NTDDI_VERSIONin a header file called TargetVer.h, which you would reference in your pre-compiled header StdAfx.h.

ADDTIONAL READING

查看更多
登录 后发表回答