Hello,
Keep in mind that IE may not be configured with a single proxy server;
instead it may be configured to use a Proxy Auto-Config (PAC) file which
must be discovered via a "Web Proxy Auto Discovery" (WPAD) protocol. The PAC
file contains JavaScript code that must be run to compute a proxy server
address (taking a destination URL as input). See
http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol for more
details.
In the WinHttp 5.1 API, there are a couple APIs that can help with all this:
WinHttpGetIEProxyConfigForCurrentUser
-- This will tell you how IE is configured for the current active
connection. It basically tells you what is set in IE under the Tools /
Internet Options / Connections / LAN Settings (or whatever connection is
active). If IE is configured to "Automatically detect settings" or "Use
automatic configuration script" then you must perform "autoproxy discovery".
If IE is configured to always use a specific proxy server, this API will
provide that information.
WinHttpGetProxyForUrl
-- This API will perform "autoproxy" discovery. Given a destination URL, it
will run the WPAD algorithm (find and download the PAC file and run the
JavaScript code), and output the proxy server address.
Information about these WinHttp APIs is available in MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/winhttp_autoproxy_api.asp
For some sample code (written in Visual Basic) that uses these APIs, take a
look at:
http://groups.google.com/group/microsoft.public.winhttp/browse_frm/thread/65e58dd978a0f368/0b079f3404c8018e?num=6#0b079f3404c8018e
Hope that helps.
Regards,
- Stephen