windows 获得 winhttp.h 的推荐方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/752006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:18:41  来源:igfitidea点击:

What's the recommended way to get winhttp.h?

c++windowsproxysdkwinhttp

提问by emk

Our application uses libcurl for HTTP, and we want to get access to Internet Explorer's proxy settings. An earlier Stack Overflow question recommends that we use WinHttpGetIEProxyConfigForCurrentUserand WinHttpGetProxyForUrl.

我们的应用程序将 libcurl 用于 HTTP,并且我们想要访问 Internet Explorer 的代理设置。较早的 Stack Overflow 问题建议我们使用WinHttpGetIEProxyConfigForCurrentUserWinHttpGetProxyForUrl

Unfortunately, the winhttp.hheader does not appear to be included with our copies either Visual C++ 2005 or Visual Studio 2008. Apparently, it's possible to download an updated Platform SDK and install it in Visual C++ 2005, but it's a pretty painful process, and it doesn't necessarily work with newer versions of Visual Studio.

不幸的是,winhttp.h标题似乎没有包含在我们的 Visual C++ 2005 或 Visual Studio 2008 副本中。显然,可以下载更新的 Platform SDK 并将其安装在 Visual C++ 2005 中,但这是一个非常痛苦的过程,并且它没有不一定适用于较新版本的 Visual Studio。

Is there a good, well-supported way to access the WinHTTP 5.1 APIs from C++? Or should we avoid using these APIs?

从 C++ 访问 WinHTTP 5.1 API 是否有一种良好的、受支持的方式?还是我们应该避免使用这些 API?

回答by snowcrash09

The best, well-supported way to access the WinHTTP 5.1 APIs from C++ is via the Windows SDK (new name for the Platform SDK) and using those APIs you mentioned.

从 C++ 访问 WinHTTP 5.1 API 的最佳、受支持的最佳方式是通过 Windows SDK(平台 SDK 的新名称)并使用您提到的那些 API。

The article you linked to suggests that installing the SDK is difficult - the good news is its an old article from 2006 and things are much easier these days. Just do the following:

您链接到的文章表明安装 SDK 很困难 - 好消息是它是 2006 年的旧文章,现在事情变得容易多了。只需执行以下操作:

  1. Download the latest SDK ISO image from here- don't worry about it being called the "SDK for Windows Server 2008", it's also for Server 2003, XP and Vista.
  2. Burn to DVD
  3. Run the setup.exe on the DVD, select full installation and let it run for 1/2 hour or so.
  4. After installation, goto Start -> Programs -> Microsoft Windows SDK -> Visual Studio Registration -> Integrate Windows SDK with Visual Studio 2005
  1. 这里下载最新的 SDK ISO 映像- 不要担心它被称为“Windows Server 2008 的 SDK”,它也适用于 Server 2003、XP 和 Vista。
  2. 刻录到 DVD
  3. 运行 DVD 上的 setup.exe,选择完全安装并让它运行 1/2 小时左右。
  4. 安装后,转到开始 -> 程序 -> Microsoft Windows SDK -> Visual Studio 注册 ->将 Windows SDK 与 Visual Studio 2005 集成

You may even be prompted to run the integration tool during installation - it's been a while since I installed it so I can't recall exactly.

甚至可能会在安装过程中提示您运行集成工具 - 我安装它已经有一段时间了,所以我记不清了。

The Visual C++ compiler will then be able to find winhttp.h and winhttp.lib in the appropriate folders.

然后,Visual C++ 编译器将能够在适当的文件夹中找到 winhttp.h 和 winhttp.lib。

UpdateAs usual things are never as simple as they should be. EMK has pointed out that the Windows SDK Configuration Tool doesn't work properly with Visual Studio 2008 (any version) and crashes after installing Visual Studio 2008 SP1. Details and workarounds are reported hereand here.

更新像往常一样,事情永远不会像应有的那样简单。EMK 曾指出 Windows SDK 配置工具在 Visual Studio 2008(任何版本)上无法正常工作,并且在安装 Visual Studio 2008 SP1 后崩溃。此处此处报告详细信息和解决方法。

回答by Susam Pal

In case anyone comes across this post and is curious about the minimal components that can be installed to get winhttp, installing Microsoft Windows Core SDK > Build Environment > Build Environment (x86 32-bit) worked for me.

如果有人看到这篇文章并且对可以安装以获得 winhttp 的最小组件感到好奇,安装 Microsoft Windows Core SDK > 构建环境 > 构建环境(x86 32 位)对我有用。

回答by Susam Pal

You absolutely don't need the whole SDK Just download the right part, see MSDN for choices.

您绝对不需要整个 SDK 只需下载正确的部分,请参阅 MSDN 以获取选择。