uses ...,WinInet;
function GetProxyInformation2(
handle:HINTERNET):
string;
var
ProxyInfo: PInternetProxyInfo;
Len: LongWord;
begin
Result := '
';
Len := 4096;
GetMem(ProxyInfo, Len);
try
if InternetQueryOption(
handle, INTERNET_OPTION_PROXY, ProxyInfo, Len)
then
if ProxyInfo^.dwAccessType = INTERNET_OPEN_TYPE_PROXY
then
begin
Result := ProxyInfo^.lpszProxy
end;
finally
FreeMem(ProxyInfo);
end;
end;
function GetProxyInformation:
string;
begin
Result := GetProxyInformation2(
nil);
end;
{**************************************************************************
* NAME: GetProxyServer
* DESC: Proxy-Server Einstellungen abfragen
* PARAMS: protocol => z.B. 'http' oder 'ftp'
*************************************************************************}
procedure GetProxyServer(protocol:
string;
var ProxyServer:
string;
var ProxyPort:Integer);
var
i : Integer;
proxyinfo :
string;
begin
ProxyServer := '
';
ProxyPort := 0;
proxyinfo := GetProxyInformation;
if proxyinfo = '
'
then
Exit;
protocol := AnsiLowerCase(protocol)+'
=';
i := Pos(protocol, proxyinfo);
if i > 0
then
begin
Delete(proxyinfo, 1, i+Length(protocol)-1);
i := Pos('
;', proxyinfo);
if i=0
then
i := Pos('
', proxyinfo);
if i > 0
then
proxyinfo := Copy(proxyinfo, 1, i-1);
end;
i := Pos('
:', proxyinfo);
if i > 0
then
begin
ProxyPort := StrToIntDef(Copy(proxyinfo, i+1, Length(proxyinfo)-i), 0);
ProxyServer := Copy(proxyinfo, 1, i-1)
end
end;