Refer to the followingCode
// Download HTTP file through proxy
Cstring gehttptfile (cstring Surl)
{
Cstring scontent;
Char sproxylist [max_path], susername [64], spassword [64];
// In this case "proxya" is the proxy server name, and "8080" is its port
Strcpy (sproxylist, "proxya: 8080 ");
Strcpy (susername, "myusername ");
Strcpy (strpassword, "mypassword ");
DWORD dwservicetype = afx_inet_service_http;
Cstring sserver, sobject;
Internet_port nport;
Afxparseurl (URL, dwservicetype, szserver, szobject, nport );
Cinternetsession mysession;
Chttpconnection * pconnection;
Chttpfile * phttpfile;
Pconnection = mysession. gethttpconnection (szserver, internet_flag_keep_connection, internet_invalid_port_number, null, null );
Phttpfile = pconnection-> openrequest ("get", szobject, null, 0, null, null, internet_flag_keep_connection );
// Here for proxy
Internet_proxy_info proxyinfo;
Proxyinfo. dwaccesstype = internet_open_type_proxy;
Proxyinfo. lpszproxy = sproxylist;
Proxyinfo. lpszproxybypass = NULL;
Mysession. setoption (internet_option_proxy, (lpvoid) & proxyinfo, sizeof (internet_proxy_info ));
Phttpfile-> setoption (internet_option_proxy_username, susername, strlen (susername) + 1 );
Phttpfile-> setoption (internet_option_proxy_password, spassword, strlen (spassword) + 1 );
Phttpfile-> sendrequest (null );
DWORD nfilesize = phttpfile-> getlength ();
Lpstr rbuf = scontent. getbuffer (nfilesize );
Uint ubytesread = phttpfile-> Read (rbuf, nfilesize );
Scontent. releasebuffer ();
Phttpfile-> close ();
Delete phttpfile;
Pconnection-> close ();
Delete pconnection;
Mysession. Close ();
Return scontent;
}