MFC HTTP访问URL
unsigned short nPort; //用于保存目标HTTP服务端口 CString strServer, strObject; //strServer用于保存服务器地址,strObject用于保存文件对象名称 DWORD dwServiceType, dwRet; //dwServiceType用于保存服务类型,dwRet用于保存提交GET请求返回的状态号 //解析URL,获取信息 if (!AfxParseURL("http://1.msbdutytable.applinzi.com/", dwServiceType, strServer, strObject, nPort)) { return; } //建立网络连接 if(1) { CInternetSession *session = new CInternetSession(); CHttpFile *pHtFile = NULL; CHttpConnection *pHtCon = session->GetHttpConnection(strServer, nPort); pHtFile = pHtCon->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject); pHtFile->SendRequest(); session->Close(); delete pHtCon; pHtCon = NULL; delete pHtFile; pHtFile = NULL; }
Stay hungry,stay foolish.