Hi
I wonder if somebody have some experience with how to get proxy-servers
auto-configurable addresses.
I and our company develop a software which depends on http and ftp i VB6.
Some of our customers use automatic detect proxy servers in IE6. I need to
develop the same functions for our software ( our components from IP-works needs
this settings to work). I have tested different server software to learn how
this WPAD magic works. At this moment my test-server is a win2000 server with a
DNS and a DHCP server configured to answer for incoming request, and I use MS
Proxy 2 as proxy server. My wpad.dat file is like this:
function FindProxyForURL(url, host)
{
if (url.substring(0, 5)
== "http:")
{
return "PROXY
192.168.1.1:80";
}
else if (url.substring(0, 4) == "ftp:")
{
//If I use SOCKS server for FTP like UNIX
do
//return "SOCKS
192.168.1.1:1080";
// If I use MS Proxy2 server and use the client use winsock - go
directly
return "DIRECT";
}
else
{
// Some other protocol - for test only
return
"PROXY
192.168.1.2:80";
//return
"DIRECT";
}
}
This wpad.dat file works perfectly in IE6, do I use
ftp://some-server in the adressbar it
connects perfectly.
Now to the problem, I have tried to get this info for some time now (
some weeks ) , I have used wininet.h functions to find out this. The
function DetectAutoProxyUrl perfect finds the address for my WPAD file , but the
pfnInternetGetProxyInfo in the jsproxy.dll can't resolve the correct
answer:
the code snippet:
if( !pInternetGetProxyInfo( (LPSTR)url , sizeof( url ),
(LPSTR) host, sizeof( host
),
&proxy,
&dwProxyHostNameLength ) )
{
reportFuncErr(
"InternetGetProxyInfo", myError );
*bstrFTPProxy
=A2BSTR(myError);
*lResult = -1;
return
S_OK;
}
else
{
ATLTRACE( "\n Proxy
is: %s\n", proxy );
*bstrHttpProxy = A2BSTR(proxy);
}
If I use http or ftp for my url it always report back PROXY
192.168.1.2:80
which is a wrong answer, IE6 solves this, why not this function?
The second solution is to use the new function WinHttpGetProxyForUrl in
winhttp.dll 5.1 , this function seems to resolve the correct server-address for
http addresses. But if I use some url for ftp like
ftp://some-server it answer 12006 -
ERROR_WINHTTP_UNRECOGNIZED_SCHEME. If I understands correctly winhttp don't
support ftp ?
Some info, All our code is in VB6 but this I have made in ATL/VC++ as a
object.
Is there somebody who can solve my problem. The best solution would be to
use the old functions in wininet.h mostly for our customers use win98 , NT4 and
you have to use win2k sp3 or winxp sp1 to use winhttp.dll 5.1.
In worst case I have to interp the info in the WPAD file myself.
Regards