UrlMkSetSessionOption 可以设定代理,但是如果代理服务器设定了密码,如何控制?
解决方案 »
- 调用sendto发送数据时有时中断
- 能透明显示图片的CStatic类,当被其他窗体遮挡后,显示大黑框。。
- 在调用DllMain前是不是会调用RawDllMain
- 如何实现一个多列的CListBox?
- 困惑~~
- 请教,我用VC++6.0向导产生了一个MFC应用程序,经过修改后能在主窗口中画图形,但将窗口最小化后再最大化,图形全没了,如何解决。
- 请问这样功能怎么实现?(是关于256色灰度文件黑白对比度的)
- VC的数据类型大全征集(特殊的5分,标准的2分,Up的1分:p)
- 高分!困扰总专家分1w+的csdner的一个很难的问题!关于Windows消息及doc&view问题。高手请进!
- 多线程共享数据区的问题
- 用WinInet如何获取指定URL的网页的HTML源码!
- 关于CHtmlView/CDhtmlDialog 写的浏览器虚拟内存释放问题
//--------------------------------------------------------------------------------
We can find details about Proxy Authentication and Sever Authentication methed in MSDN.
Just search for the keyword "INTERNET_OPTION_USERNAME".
Here I give a very simple example. It works in my project.
CString GeHttptFile(const char *url)
{
CString szContent;
char strProxyList[MAX_PATH], strUsername[64], strPassword[64];
//in this case "proxya" is the proxy server name, "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;
}
如何给基于chtmlview的浏览器来设定代理