Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WinInet Auto Proxy Setup Programatically

359 views
Skip to first unread message

Venkata Reddy

unread,
Jan 9, 2002, 2:17:29 PM1/9/02
to
Hi,

How do I set up WinInet programatically to use AutoProxy config script
file(pac file), so that it gets the proxy info from pac file. I want my
application to access the proxy info the way IE does when Auto proxy config
option is selected. I'm using the WinInet APIs, and is there anyway in
WinInet to set this file option. My application is C. I read somewhere in
MSDN saying that WinInet supports autoproxy configuration. But couldn't find
any sample code to do that. I used following code which sets the IE5.0
Autoconfig options, but still no use.
This code is updating the IE's options.
INTERNET_PER_CONN_OPTION_LIST List;
INTERNET_PER_CONN_OPTION Option[2];
unsigned long nSize =
sizeof(INTERNET_PER_CONN_OPTION_LIST);

Option[0].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL;
Option[0].Value.pszValue = "http://myserver/proxy.pacl;
Option[1].dwOption = INTERNET_PER_CONN_FLAGS;
Option[1].Value.dwValue = PROXY_TYPE_AUTO_PROXY_URL;

List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
List.pszConnection = NULL;
List.dwOptionCount = 2;
List.dwOptionError = 0;
List.pOptions = Option;

hMyHandle = InternetOpen("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);

if(!InternetSetOption(hMyHandle, INTERNET_OPTION_PER_CONNECTION_OPTION,
&List, nSize))
printf("InternetQueryOption failed! (%d)\n", GetLastError());

Thanks in advance for the help

Venkat


Brian Combs

unread,
Jan 14, 2002, 2:40:49 PM1/14/02
to
Hello
There is no direct way to do this with WinInet. However the resolution below
will explain the steps needed in order to find out which proxy is being
used
in the pac file.

*** Resolution ***
Wininet API's do not make the proxy server information available when using
an automatic configuration script. You will need to create your own
implementation for PAC file support. The first thing you will need to do
is make your application host the script engine.
Q221992 HOWTO: Add Support for Hosting VBScript to Your MFC Application
<http://support.microsoft.com/support/kb/articles/q221/9/92.asp>
and
Q183698 SAMPLE: AXSH.EXE Demonstrates Implementing ActiveX Script Hosts
<http://support.microsoft.com/support/kb/articles/Q183/6/98.ASP>
You will then need to provide implementations of the functions needed to
process a PAC file. The functions IE supports are listed in
Q209266 Auto-Proxy Functions Supported by Internet Explorer
<http://support.microsoft.com/support/kb/articles/q209/2/66.asp> .
The link to Netscape's documentation is dead, but you can find the same
information at
<http://developer.netscape.com/docs/manuals/proxy/adminux/autoconf.htm> .

Other helpful links
Q226473 HOWTO: Query and Set Proxy Settings Under Internet Explorer
<http://support.microsoft.com/support/kb/articles/Q226/4/73.ASP>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/h
tml/scripting.asp>

Thanks
Brian [MS]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.

newl...@gmail.com

unread,
Jan 5, 2016, 4:40:24 PM1/5/16
to
0 new messages