'Windows.h: 将平台工具集更改为 v140_xp 时出现“没有这样的文件或目录”错误

'Windows.h: No such file or directory" error when changing Platform Toolset to v140_xp

我试图为 Windows XP 编译一个应用程序;正常的可执行文件给出错误:

"... is not a valid Win32 application."

我读到我可以通过将平台工具集更改为 Visual Studio 2015 - Windows XP (v140_xp) 来创建与 XP 兼容的可执行文件,但是当我这样做然后尝试编译时,它会出现以下错误:

Cannot open include file: 'Windows.h': No such file or directory

Could not find WindowsSdkDir_71A variable from registry. TargetFrameWorkVersion or Platform toolset may be set to an invalid version number.

如何使用此工具集版本进行编译?

将平台工具集设置为 Visual Studio 2015 - Windows XP (v140_xp) 后,您关闭 VS 2015 并重新打开您的项目。它会自动弹出一个窗口,告诉您安装一些文件以支持 Windows XP 项目。