views:

1880

answers:

3

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?

+10  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:

  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

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.

snowcrash09
Thanks! Is the full installation actually necessary, or could we get away with only installing (for example) the relevant C++ parts?
emk
I forget what options there are - you can probably get away with just the Win32 headers and libraries. However, I normally install absolutely everything, since disk space is cheap but presumably your time (to figure out what components you need) is not.
snowcrash09
Fair enough! We need to install it on a lot of machines, so I figured it might be worth figuring out which components we actually need. Thanks for the advice!
emk
To make this work, see: http://social.msdn.microsoft.com/forums/en-US/windowssdk/thread/62b7d1a6-5210-4f1e-8fc5-a06193edce22/ and http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/7d0eafe5-477b-40cc-85a1-cd6296c6b745 . Could you please link to these pages in your answer?
emk
Thanks for the links! Accepted.
emk
A: 

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

I agree you don't *need* the whole thing, but for many people figuring out the right part is more expensive than just installing all of it.
snowcrash09
+2  A: 

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.

Susam Pal