如何自动获得IE设置的代理服务器地址?(100分)

  • 主题发起人 主题发起人 tomore
  • 开始时间 开始时间
T

tomore

Unregistered / Unconfirmed
GUEST, unregistred user!
如题
谢谢!
 
HKEY_USERS/Software/Microsoft/Windows/CurrentVersion/Internet Settings
中的子键:ProxyServer,ProxyEnable
自动获得不知道是什么意思
 
还跟IE版本有关,IE3/4/5 有区别
 
uses WinInet;

procedure GetDefaultProxyServer(var Server, ByPass: string; var Port: Integer);
const
BUF_SIZE: DWORD = 500;
var
ProxyInfo: PInternetProxyInfo;
Buffer: Pointer;
begin
GetMem(Buffer, BUF_SIZE);
try
if not InternetQueryOption(nil, INTERNET_OPTION_PROXY, Buffer, BUF_SIZE) then
RaiseLastWin32Error;
ProxyInfo := Buffer;
ByPass := ProxyInfo^.lpszProxyBypass;
if (ProxyInfo^.lpszProxy = '') then begin
Server := '';
Port := 0;
end else with TStringTokenizer.Create(ProxyInfo^.lpszProxy, [':']) do try
Server := NextToken;
if HasMoreTokens then
Port := StrToInt(NextToken)
else
Port := 0;
finally
Free;
end;
finally
FreeMem(Buffer);
end;
end;

 
lookee:
编译通不过呀
麻烦你再次指点。
 
稍微改了一下,这回能运行了
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;
 
接受答案了.
 
后退
顶部