How can I determine the version of the Windows SDK installed on my computer?

后端 未结 5 1880
死守一世寂寞
死守一世寂寞 2020-12-29 17:46

I\'ve very recently decided to teach myself c++ and win32 programming after learning vb.net, and I\'ve got a very simple question:

5条回答
  •  情话喂你
    2020-12-29 18:32

    If you need to determine, while compiling, what major OS version of the Windows SDK is being used then you can use the VER_PRODUCTBUILD macro, which is defined in ntverp.h. For instance:

    #include 
    #if VER_PRODUCTBUILD > 9600
    // Windows 10+ SDK code goes here
    #else
    // Windows 8.1- SDK code goes here
    #endif
    

    In most cases this should not be necessary because a product should be designed to build with a particular platform SDK. But for some large products there may be a desired to support multiple platform SDKs. This can be particularly useful when migrating from one to another. If there is a bug in a header file (such as the bogus "#pragma pop" in the Windows 8.1 SDK version of bthledef.h) then you may need to workaround this bug, but not include the workaround when using the Windows 10 SDK or higher. This technique can also be used to give helpful error messages if the required SDK version is not installed.

    Note that VER_PRODUCTBUILD only gives major OS version information, such as 8.1 versus 10. That means that VER_PRODUCTBUILD is increasingly useless as it doesn't change with the updates to Windows 10. Therefore the more likely thing to look at is sdkddkver.h and the NTDDI_WIN10_* macros. As of the Windows 10.0.17763.0 SDK NTDDI_WIN10_RS5 is now defined. So, write code like this:

    #include 
    #if !defined(NTDDI_WIN10_RS5)
        #error Windows 10.0.17763.0 SDK is required
    #endif
    

提交回复
热议问题