如何在Microsoft Visual Studio C ++中定位Windows XP [英] How to target Windows XP in Microsoft Visual Studio C++

查看:123
本文介绍了如何在Microsoft Visual Studio C ++中定位Windows XP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 8.1上使用Microsoft Visual Studio 2015。我想编译一个针对Windows XP的程序。我在Google和其他类似问题上进行了查询,但都无济于事。在解决方案设置中,目标平台工具集设置为Windows XP,但目标平台版本中没有Windows XP选项。
我确实阅读了



这是因为默认的Platform Toolset使用Windows 8.1 SDK(或者您可以选择使用Windows 10 SDK),并且仅支持构建适用于Windows Vista或更高版本的应用程序。选择 v140_xp 平台工具集时,您使用的是Windows 7.1 SDK版本,这是支持以Windows XP或Windows Server 2003为目标的最新版本。


请注意,Visual Studio可以定位Windows XP Service Pack 3或Windows Server 2003 Service Pack2。C/ C ++运行时与Windows的旧版本不兼容。


如果您在应用程序中使用DirectX,这将产生深远的影响,因为Windows 7.1 SDK和Windows之间发生了很大的变化。 8 SDK。请参阅


I'm using Microsoft Visual Studio 2015 on Windows 8.1. I want to compile a program targeting Windows XP. I've looked it up on Google and other similar questions, but none helped. In the solution settings, target platform toolset is set to the Windows XP one, but there is no option for Windows XP in the target platform version. I did read https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx (Using the Windows Headers) and added these lines to my program:

#define WINVER _WIN32_WINNT_WINXP
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#define NTDDI_VERSION NTDDI_WINXP

But it still doesn't work. It says that it can't find "MSVCP140.dll". After I got this dll, it begins to complain about can't find "VC140.dll". After that is "ucrtbased.dll", and then finally "api-ms-win-core-string-11-1-0.dll", which I don't even have it in my Windows 8.1 computer. The program can run on Windows 8.1, but not Windows XP. What can I do to make the program run on Windows XP?

解决方案

In order to build a Windows XP compatible EXE with VS 2015 (or VS 2012 / VS 2013) you have to use the v140_xp Platform Toolset rather than the default v140 Platform Toolset.

UPDATE: Note that VS 2017 includes support for Windows XP via v141_xp. For VS 2019, this feature is no longer being updated but you can still install the v141_xp toolset to use with the VS 2019 IDE.

See your Project Properties, the General page:

This is because the default Platform Toolset uses the Windows 8.1 SDK (or you can opt into the Windows 10 SDK), and this only supports building applications for Windows Vista or later. When you select the v140_xp Platform Toolset, you are using a version of the Windows 7.1 SDK which was the last version to support targeting Windows XP or Windows Server 2003.

Note that Visual Studio can target Windows XP Service Pack 3 or Windows Server 2003 Service Pack 2. The C/C++ Runtime is not compatible with older versions of Windows.

If you are using DirectX in your app, this has some profound implications because a lot changed between the Windows 7.1 SDK and the Windows 8 SDK. See this post for details.

With VS 2015, you will also need to select the Windows XP support in the Custom Install options or via Programs & Features / Microsoft Visual Studio 2015 / Change... / Modify:

这篇关于如何在Microsoft Visual Studio C ++中定位Windows XP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆