简体   繁体   English

Visual Studio 2017中的Windows SDK版本设置

[英]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. 我有一个在Visual Studio 2013下编译得很好的c ++项目。今天我安装了Visual Studio 2017 Professional Edition,然后在项目设置> General中有一个名为“Windows SDK Version”的新设置,默认为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? 由于我正在编译用于Windows 7系统的Windows桌面程序,我将其更改为8.1,这是正确的吗?

Indeed I raised this issue because my freshly installed Visual Studio could not build the VM because SDK 16299 is now indeed the default. 实际上我提出了这个问题,因为我刚刚安装的Visual Studio无法构建VM,因为SDK 16299现在确实是默认的。 It's mentioned here: https://en.wikipedia.org/wiki/Microsoft_Windows_SDK . 它在这里提到: https//en.wikipedia.org/wiki/Microsoft_Windows_SDK . Also MS does not make finding older SDK's very easy. 此外,MS不会让寻找旧的SDK变得非常简单。 You have to click through to another page all the way on the end of this page: https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk Even though I googled on "Microsoft Windows SDK 15063". 你必须在本页末尾点击进入另一个页面: https//developer.microsoft.com/en-us/windows/downloads/windows-10-sdk即使我搜索了“Microsoft Windows SDK” 15063" 。 . So all-in-all it's now a small chore for newbies to get up and running on the VM. 总而言之,对于新手来说,在VM上启动和运行它现在是一件小事。 To start, I think it should be made as easy as possible. 首先,我认为应该尽可能简单。 (Complexity will come soon after that :)). (复杂性将很快到来:))。 . PS I'm not sure about Windows 7 compatibility. PS我不确定Windows 7的兼容性。 But the current VM SDK is also listed as being for Windows 10. 但是当前的VM SDK也列为Windows 10。

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. 一般来说,Windows SDK支持其“主”版本以及之前版本,但您需要指定程序所需的Windows版本。 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. 给定SDK,您可以通过在项目文件中的某个位置或Visual Studio中的C / C ++预处理器项目设置中定义WINVER和_WIN32_WINNT宏来指定要定位的旧Windows版本。

For example, the following definitions target Windows 7: 例如,以下定义针对Windows 7:

#define WINVER 0x0601
#define _WIN32_WINNT 0x0601

For more information, see Using the Windows Headers and Modifying WINVER and _WIN32_WINNT 有关更多信息,请参阅使用Windows标头修改WINVER和_WIN32_WINNT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM