稍微改了一下,这回能运行了
procedure GetDefaultProxyServer(var Server, ByPass: string; var Port: Integer);
var
ProxyInfo: PInternetProxyInfo;
Buffer: Pointer;
BufSize: DWORD;
I: Integer;
begin
BufSize := 500;
GetMem(Buffer, BufSize);
try
if not InternetQueryOption(nil, INTERNET_OPTION_PROXY, Buffer, BufSize) then
RaiseLastWin32Error;
ProxyInfo := Buffer;
ByPass := ProxyInfo^.lpszProxyBypass;
Server := ProxyInfo^.lpszProxy;
if (ProxyInfo^.lpszProxy = '') then begin
Server := '';
Port := 0;
end else
begin
I := Pos(':', Server);
Port := StrToInt(copy(Server, I +1, Length(Server) -I));
Server := copy(Server, 1, I -1);
end;
finally
FreeMem(Buffer);
end;