1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62:
| uses SysUtils, WinInet;
type TIEProxyServer = record Protocol, Server: string; Port: Integer end;
function GetIEProxyServer (aProtocol: string) : TIEProxyServer;
function GetProxyInformation: string; var ProxyInfo: PInternetProxyInfo; Len: LongWord; begin Result := ''; Len := 4096; GetMem(ProxyInfo, Len); try if InternetQueryOption(nil, INTERNET_OPTION_PROXY, ProxyInfo, Len) then if ProxyInfo^.dwAccessType = INTERNET_OPEN_TYPE_PROXY then begin Result := ProxyInfo^.lpszProxy end; finally FreeMem(ProxyInfo); end; end;
var i: Integer; ProxyInfoStr : string; begin Result.Protocol := aProtocol; Result.Server := ''; Result.Port := 0;
ProxyInfoStr := GetProxyInformation; if ProxyInfoStr = '' then Exit;
aProtocol := aProtocol + '=';
i := Pos (aProtocol, ProxyInfoStr); if i > 0 then begin Delete (ProxyInfoStr, 1, i + Length (aProtocol)); i := Pos (';', Result.Server); if i > 0 then ProxyInfoStr := Copy (ProxyInfoStr, 1, i - 1); end;
i := Pos (':', ProxyInfoStr); if i > 0 then begin Result.Port := StrToIntDef (Copy(ProxyInfoStr, i + 1, Length (ProxyInfoStr) - i), 0); Result.Server := Copy (ProxyInfoStr, 1, i - 1) end end; |