Home > Back-end >  BCB6 TCppWebBrowser Navigate how to change the IE setting not use Proxy has a user name and password
BCB6 TCppWebBrowser Navigate how to change the IE setting not use Proxy has a user name and password

Time:10-07

BCB 6 using TCppWebBrowser Navigate through a Proxy to access a particular web site, but don't want to change the existing Proxy Settings in the browser, how to implement??



CodePudding user response:

CInternetSession session;

CHttpFile * pFile=NULL;
INTERNET_PROXY_INFO proxyInfo;
ProxyInfo. DwAccessType=INTERNET_OPEN_TYPE_PROXY;
ProxyInfo. LpszProxy=_T (192.168.1.21: "8080");
ProxyInfo. LpszProxyBypass=NULL;
AnsiString UserName="usr";
AnsiString UserPassWord=password ";

The session. SetOption (INTERNET_OPTION_PROXY, (LPVOID) & amp; ProxyInfo, sizeof (INTERNET_OPTION_PROXY), 0);
UrlMkSetSessionOption (INTERNET_OPTION_PROXY, & amp; ProxyInfo, sizeof (proxyInfo), 0);

CHttpConnection * pConnection=session. GetHttpConnection (_T (" www.baidu.com "));
Session. SetOption (INTERNET_OPTION_PROXY_USERNAME, UserName. C_str (), dwords (UserName. The Length ()) + 1);
Session. SetOption (INTERNET_OPTION_PROXY_PASSWORD, UserPassWord c_str (), dwords (UserPassWord. The Length ()) + 1);
If (pConnection==NULL)
{
ShowMessage (" I'm sorry, connect to the server failed!" );
return;
}
WebBrowser1 - & gt; Navigate (L "http://www.baidu.com");

PConnection - & gt; Close ();

The delete pConnection;
The session. The Close ();
return;
  • Related