3

如何正确使用需要身份验证的代理。波纹管代码仅适用于不需要授权的代理。

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;
4

1 回答 1

0

我注意到很多人喜欢用手鼓跳舞。;/

procedure TForm1.FormCreate(Sender: TObject);
begin
embeddedwb1.ProxySettings.SetProxy('ololo user agent','yourProxyServer:port');
embeddedwb1.Navigate('about:blank'); // still use proxy
embeddedwb1.Navigate('your URI here');
end;
于 2015-11-05T21:38:37.783 回答