代码如下 CInternetSession session;
CHttpConnection *pServer=NULL;
CHttpFile *pFile=NULL;
CString m_site_address("http://www.sina.com.cn/");
INTERNET_PORT nPort;
DWORD dwServiceType;
CString strObject;
CString strServer;
if(!AfxParseURL(m_site_address,dwServiceType,strServer,strObject,nPort)||
dwServiceType != INTERNET_SERVICE_HTTP)
{
MessageBox(_T("不是HTTP站点"),_T("错误"));
} pServer=session.GetHttpConnection(m_site_address,nPort);
pFile=pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,strObject);//,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT); pFile->AddRequestHeaders(_T("My Browser"));
//下面的sendrequest 抛出 the url is invliad 异常
pFile->SendRequest();
CHttpConnection *pServer=NULL;
CHttpFile *pFile=NULL;
CString m_site_address("http://www.sina.com.cn/");
INTERNET_PORT nPort;
DWORD dwServiceType;
CString strObject;
CString strServer;
if(!AfxParseURL(m_site_address,dwServiceType,strServer,strObject,nPort)||
dwServiceType != INTERNET_SERVICE_HTTP)
{
MessageBox(_T("不是HTTP站点"),_T("错误"));
} pServer=session.GetHttpConnection(m_site_address,nPort);
pFile=pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,strObject);//,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT); pFile->AddRequestHeaders(_T("My Browser"));
//下面的sendrequest 抛出 the url is invliad 异常
pFile->SendRequest();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货