CInternetSession session;
CHttpFile *file = NULL; CString
strURL = _T("http://www.baidu.com");
CString strHtml = _T(""); //存放网页数据
try
{ file
=
(CHttpFile*)session.OpenURL(strURL);
} catch(CInternetException
*
m_pException)
{ file = NULL;
m_pException->m_dwError;
m_pException->Delete();
session.Close(); AfxMessageBox(_T("CInternetException"));
} CString strLine; char
sRecived[1024];
if(file != NULL) {
while(file->ReadString((LPTSTR)sRecived,1024)
!=
NULL) {
strHtml += sRecived; } }
else
{
AfxMessageBox(_T("fail")); } session.Close();
file->Close();
delete file; file = NULL;