Search code examples
c++visual-studio-2017

Windows SDK Version setting in Visual Studio 2017


I have a c++ project that compiles well under Visual Studio 2013. Today I installed Visual Studio 2017 Professional Edition, then there's a new setting in project settings > General called "Windows SDK Version", by default is 10.0.16299.0. Since I'm compiling windows desktop programs for targeting Windows 7 systems, I changed it to 8.1, is this correct?


Solution

  • Generally speaking, a Windows SDK supports its "main" version and also the previous ones, but you need to specify what Windows version your program will need. In fact, you're better off doing so or else you can inadvertently use features not available in the version you want to support.

    Given an SDK, you indicate which older Windows version to target by defining the WINVER and _WIN32_WINNT macros somewhere in your project files or in the C/C++ Preprocessor project settings in Visual Studio.

    For example, the following definitions target Windows 7:

    #define WINVER 0x0601
    #define _WIN32_WINNT 0x0601
    

    For more information, see Using the Windows Headers and Modifying WINVER and _WIN32_WINNT