如何正确使用需要身份验证的代理。波纹管代码仅适用于不需要授权的代理。
procedure SetProxy(username, password, proxy: ansistring);
var
proxy_info : PInternetProxyInfo;
begin
New(proxy_info);
UrlMkSetSessionOption(INTERNET_OPTION_PROXY_USERNAME, PAnsichar(username), Length(username)+1, 0);
UrlMkSetSessionOption(INTERNET_OPTION_PROXY_PASSWORD, PAnsichar(password), Length(password)+1, 0);
proxy_info^.dwAccessType := INTERNET_OPEN_TYPE_PROXY;
proxy_info^.lpszProxy := PAnsiChar(proxy);
proxy_info^.lpszProxyBypass := PAnsiChar('');
UrlMkSetSessionOption(INTERNET_OPTION_PROXY, proxy_info, SizeOf(Internet_Proxy_Info), 0);
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
SetProxy('username','password','YYY.YYY.YYY.YYY:XXX');
EmbeddedWB1.Navigate('http://www.whatsmyuseragent.com/');
end;