A piece of code Excerpted from the csdn forum post
// Download HTTP file through proxy
Cstring gehttpfile (const char * URL)
{
Cstring szcontent;
Char strproxylist [max_path], strusername [64], strpassword [64];
// In this case "proxya" is the proxy server name, and "8080" is its port
Strcpy (strproxylist, "proxya: 8080 ");
Strcpy (strusername, "myusername ");
Strcpy (strpassword, "mypassword ");
DWORD dwservicetype = afx_inet_service_http;
Cstring szserver, szobject;
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 = strproxylist;
Proxyinfo. lpszproxybypass = NULL;
Mysession. setoption (internet_option_proxy, (lpvoid) & proxyinfo, sizeof (internet_proxy_info ));
Phttpfile-> setoption (internet_option_proxy_username, strusername, strlen (strusername) + 1 );
Phttpfile-> setoption (internet_option_proxy_password, strpassword, strlen (strpassword) + 1 );
Phttpfile-> sendrequest (null );
DWORD nfilesize = phttpfile-> getlength ();
Lpstr rbuf = szcontent. getbuffer (nfilesize );
Uint ubytesread = phttpfile-> Read (rbuf, nfilesize );
Szcontent. releasebuffer ();
Phttpfile-> close ();
Delete phttpfile;
Pconnection-> close ();
Delete pconnection;
Mysession. Close ();
Return szcontent;
}