Visual C++ 应用程序不会 运行 on windows 7
Visual C++ application won't run on windows 7
我正在使用 Visual Studio Community 2015,我编写了一些简单的 Win32 演示应用程序,它应该从 Internet 下载文件并执行两个 HTTP GET 请求。
我正在使用 InternetOpenA
、InternetConnectA
、HttpOpenRequestA
、URLDownloadToFile
等函数
我在设置中唯一更改的是 Platform Toolset 到 Visual Studio 2013 (v120) 和我的 targetver.h
文件如下所示:
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <WinSDKVer.h>
#define WINVER 0x0600
#define _WIN32_WINNT 0x0600
#include <SDKDDKVer.h>
但是,它 运行 在我的 Windows 10 计算机上,但在 windows 7 上没有 运行。它说:缺少 MSVCR120.dll文件。我可以安装适当的 C++ Redistributables,但这不是我需要的解决方案。
编译时是否需要包含任何其他选项以避免此错误?
为避免您的应用程序需要单独的运行时 DLL,请在项目设置中查看:
C/C++ > 代码生成 > 运行时库
并选择多线程,而不是多线程 DLL。
您不需要更改平台工具集。
在我的项目中,我使用 VS 2017 编译并希望 运行 一直到 Vista,我和你做的一样,但没有第一个 #include <WinSDKVer.h>
。我只是将 _WIN32_WINNT
宏设置为 0x0600
,到目前为止它工作正常。
我的目标是 Windows 8.1 SDK,如果有帮助,我会使用 MFC。
我过去曾使用 dependency walker 来诊断 dll 依赖关系。希望它是一些愚蠢的东西,比如 32 位或 64 位 运行 次丢失。
正如 keith 在他的回答中所建议的那样,您还可以尝试静态链接 vc 运行time(/MT[d] 在 C++/代码 generation/Runtime 库下)以便它不需要将 运行time 作为 dll 加载。请注意,这不是推荐的选项,因为 VC 运行time 无法通过 Windows Update 修补,如果它被刻录到您的可执行文件中。
我正在使用 Visual Studio Community 2015,我编写了一些简单的 Win32 演示应用程序,它应该从 Internet 下载文件并执行两个 HTTP GET 请求。
我正在使用 InternetOpenA
、InternetConnectA
、HttpOpenRequestA
、URLDownloadToFile
等函数
我在设置中唯一更改的是 Platform Toolset 到 Visual Studio 2013 (v120) 和我的 targetver.h
文件如下所示:
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <WinSDKVer.h>
#define WINVER 0x0600
#define _WIN32_WINNT 0x0600
#include <SDKDDKVer.h>
但是,它 运行 在我的 Windows 10 计算机上,但在 windows 7 上没有 运行。它说:缺少 MSVCR120.dll文件。我可以安装适当的 C++ Redistributables,但这不是我需要的解决方案。
编译时是否需要包含任何其他选项以避免此错误?
为避免您的应用程序需要单独的运行时 DLL,请在项目设置中查看:
C/C++ > 代码生成 > 运行时库
并选择多线程,而不是多线程 DLL。
您不需要更改平台工具集。
在我的项目中,我使用 VS 2017 编译并希望 运行 一直到 Vista,我和你做的一样,但没有第一个 #include <WinSDKVer.h>
。我只是将 _WIN32_WINNT
宏设置为 0x0600
,到目前为止它工作正常。
我的目标是 Windows 8.1 SDK,如果有帮助,我会使用 MFC。
我过去曾使用 dependency walker 来诊断 dll 依赖关系。希望它是一些愚蠢的东西,比如 32 位或 64 位 运行 次丢失。
正如 keith 在他的回答中所建议的那样,您还可以尝试静态链接 vc 运行time(/MT[d] 在 C++/代码 generation/Runtime 库下)以便它不需要将 运行time 作为 dll 加载。请注意,这不是推荐的选项,因为 VC 运行time 无法通过 Windows Update 修补,如果它被刻录到您的可执行文件中。