You can use InternetQueryOption with INTERNET_OPTION_PER_CONNECTION_OPTION
to query Internet Explorer's proxy configuration. This option will let your
application discover what connection options are set (automatically
detect/use auto-config script/use a specific proxy server/etc.)
There is an article showing how to use this WinInet option at:
http://support.microsoft.com/default.aspx?scid=kb;en-us;226473
I do not know of ".ini" files that are used to configure IE proxy
settings--perhaps you mean ".ins"? .Ins files are "browser branding"
installation scripts that can customize IE, including the proxy
configuration. You cannot pass the contents of an .ins file to JSPROXY.DLL.
JSPROXY only understands javascript code. (Javascript proxy auto-config
script files typically have a ".pac", ".js" or ".jvs" file extension.)
.Ins files are processed by a DLL called IEDKCS32.DLL. Although IEDKCS32.DLL
implements the InternetInitializeAutoProxyDll API, it does not implement
InternetGetProxyInfo. The interface to this DLL does not appear to be
documented. I do not think that WinInet directly interacts with IEDKCS32
like it does JSPROXY. Instead, I think that the .ins file is processed once
by an IEAK Installation Wizard program, which then would configure IE's
proxy settings.
I wouldn't worry about .ins files unless querying the IE proxy configuration
(via PER_CONNECTION_OPTION) returns an .ins file. In that case, I think you
will have to parse the file yourself to get the proxy configuration (such as
a pointer to a .pac file which you would then send to JSPROXY).
.Ins files are documented in the Internet Explorer Administrator Kit (IEAK).
(http://www.microsoft.com/windows/ieak/default.mspx)
So the general flow is:
- Query the IE proxy configuration using
INTERNET_OPTION_PER_CONNECTION_OPTION. Note that IE proxy settings are
per-connection. That is, the proxy settings for the default LAN connection
can be different than the proxy config for a modem dialup or VPN connection.
Figuring out which connection is currently active is a whole other
complication. An example case where the proxy configurations could be
different would be a laptop that is used both on a corporate network and
from a home Internet connection.
- if IE is configured to "automatically detect", call DetectAutoProxyUrl to
try to get a URL to a .pac file.
- if DetectAutoProxyUrl returns a URL, then download the .pac file from
that URL
- if DetectAutoProxyUrl fails or "automatically detect" is not set, then
check if "use auto-config script" is specified in the IE proxy config.
- if yes, then download the specified .pac file
- if you have downloaded a .pac file, load JSPROXY, give it the .pac file
and use InternetGetProxyInfo to query for a proxy server
- if there is no proxy auto-config file to use, check if the IE proxy config
specifies a specific proxy server.
- if not, then access sites directly.
Finally, please note that if you only intend to support Windows XP SP1/SP2,
Windows 2000 SP3/SP4, and Windows Server 2003, you should consider using the
"autoproxy" APIs provided by WinHTTP 5.1 instead. The WinHTTP autoproxy APIs
are a lot easier to use than WinInet/JSPROXY.
Good luck.
Stephen
Post by Peter CarlsonOk...here is what we have decided to do...although I need some help in some
of the flow.
Determine if either of the 2 automatic proxy buttons are checked
if so use the auto detection in jscript.dll
otherwise use internetqueryoption and get the static proxy info
if both result in empty proxy strings then assume a direct connection.
The problem I am having is determining if "automatically detect settings" or
"Use automatic configuration script" are checked. When I run the tests
using pfnInternetGetProxyInfo they work and successfully complete the proxy
checks and return the correct proxy info even if the checkboxes are
unchecked.
Also, since I cant verify this by unchecking "automaticall detect settings"
if it is unchecked and there is a automatic configuration script in place,
will InternetGetProxyInfo still work?
Finally, some installations use an .ini file that points to the .pac file.
Will the InternetGetProxyInfo() method work with that scenario?
Peter