积极答复者
如何获取网页文件的大小 socket

问题
答案
-
#include <afxinet.h>
try
{
CInternetSession session(_T("session"));
CHttpFile* pFile = (CHttpFile*)session.OpenURL(_T("http://www.sina.com.cn"));
DWORD dwStatus = 0;
CString strText;
if(pFile->QueryInfo(HTTP_QUERY_CONTENT_LENGTH, strText))
{
AfxMessageBox(strText);
}
pFile->Close();
session.Close();
}
catch(CException* e)
{
e->ReportError();
e->Delete();
}
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.- 已标记为答案 VisualElevenModerator 2011年4月14日 2:58
-
用TCP socket连接那个网页,然后用GET指令获取http头部,里面有Content-Length字段,就是网页大小了
0xBAADF00D- 已标记为答案 VisualElevenModerator 2011年4月14日 2:58
全部回复
-
#include <afxinet.h>
try
{
CInternetSession session(_T("session"));
CHttpFile* pFile = (CHttpFile*)session.OpenURL(_T("http://www.sina.com.cn"));
DWORD dwStatus = 0;
CString strText;
if(pFile->QueryInfo(HTTP_QUERY_CONTENT_LENGTH, strText))
{
AfxMessageBox(strText);
}
pFile->Close();
session.Close();
}
catch(CException* e)
{
e->ReportError();
e->Delete();
}
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.- 已标记为答案 VisualElevenModerator 2011年4月14日 2:58
-
用TCP socket连接那个网页,然后用GET指令获取http头部,里面有Content-Length字段,就是网页大小了
0xBAADF00D- 已标记为答案 VisualElevenModerator 2011年4月14日 2:58