废话不多说,直接上代码:(主要是用了一个MFC类,在头文件afxinet.h里有定义,必须包含进来。在VC6.0上把基础类库设置成共享动态链接库模式就可以跑了,Project-->Settings-->Setting for选All Configuration,在General选项卡里把Microsoft Foundation Classes设置成Use MFC in a Shared DLL)
-
#include <stdio.h>
-
#include <afxinet.h>
-
-
int main(int argc, char* argv[])
-
{
-
CInternetSession session("HttpClient");
-
char * url = "";
-
CHttpFile* pfile = (CHttpFile *)session.OpenURL(url);
-
-
DWORD dwStatusCode;
-
pfile -> QueryInfoStatusCode(dwStatusCode);
-
if(dwStatusCode == HTTP_STATUS_OK)
-
{
-
CString content;
-
CString data;
-
while (pfile -> ReadString(data))
-
{
-
content += data + "\r\n";
-
}
-
content.TrimRight();
-
printf(" %s\n " ,(LPCTSTR)content);
-
}
-
pfile -> Close();
-
delete pfile;
-
session.Close();
-
-
getchar();
-
return 0 ;
-
}
阅读(7886) | 评论(0) | 转发(0) |