what is SDKDDKVer.h for?

前端 未结 2 1084
太阳男子
太阳男子 2020-12-05 14:29

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 w

相关标签:
2条回答
  • 2020-12-05 14:48

    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.

    0 讨论(0)
  • 2020-12-05 14:57

    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

    • Modifying WINVER and _WIN32_WINNT
    • Using the Windows Headers
    • What does the Target Platform Version mean for a VS C++ project?
    0 讨论(0)
提交回复
热议问题