获取 winhttp.h 的推荐方法是什么?
我们的应用程序使用 libcurl 进行 HTTP,并且我们希望访问 Internet Explorer 的代理设置。 早期的 Stack Overflow 问题建议我们使用 WinHttpGetIEProxyConfigForCurrentUser< /code> 和
WinHttpGetProxyForUrl
。
不幸的是,winhttp.h
标头似乎没有包含在我们的 Visual C++ 2005 或 Visual Studio 2008 副本中。显然,可以下载更新的 Platform SDK 并将其安装在 Visual C++ 2005 中,但这是一个非常痛苦的过程,并且它不一定适用于较新版本的 Visual Studio。
是否有一种良好的、受良好支持的方法从 C++ 访问 WinHTTP 5.1 API? 或者我们应该避免使用这些 API?
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 WinHttpGetIEProxyConfigForCurrentUser
and WinHttpGetProxyForUrl
.
Unfortunately, the winhttp.h
header 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.
Is there a good, well-supported way to access the WinHTTP 5.1 APIs from C++? Or should we avoid using these APIs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从 C++ 访问 WinHTTP 5.1 API 的最佳且受良好支持的方法是通过 Windows SDK(Platform SDK 的新名称)并使用您提到的那些 API。
您链接到的文章表明安装 SDK 很困难 - 好消息是它是 2006 年的旧文章,现在事情变得容易多了。 只需执行以下操作:
在安装过程中甚至可能会提示您运行集成工具 - 我安装它已经有一段时间了,所以我记不清了。
然后,Visual C++ 编译器将能够在相应的文件夹中找到 winhttp.h 和 winhttp.lib。
更新 与往常一样,事情永远不会像应有的那么简单。 EMK 指出,Windows SDK 配置工具无法与 Visual Studio 2008(任何版本)一起正常工作,并且在安装 Visual Studio 2008 SP1 后会崩溃。 此处报告了详细信息和解决方法 和此处< /a>.
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.
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:
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.
Update As 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 here and here.
如果有人看到这篇文章并对可以安装以获得 winhttp 的最小组件感到好奇,请安装 Microsoft Windows Core SDK > 搭建环境> 构建环境(x86 32 位)对我有用。
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.
您绝对不需要整个 SDK
只需下载正确的部分即可,请参阅 MSDN 进行选择。
You absolutely don't need the whole SDK
Just download the right part, see MSDN for choices.