//this code excerpt also demonstrates try/catch exception handling
#include <afxinet.h>
void DisplayHttpPage(LPCTSTR pszServerName, LPCTSTR pszFileName)
{
CInternetSession session(_T(“My Session“)); //用于建立一个网络连接
CHttpConnection* pServer = NULL; //用于管理上面建立的网络连接
CHttpFile* pFile = NULL; //用于读取或者储存文件包括本地
try
{
CString strServerName;
INTERNET_PORT nPort = 80;
DWORD dwRet = 0;
pServer = session.GetHttpConnection(pszServerName, nPort); //这个就是常规用法即:
//CHttpConnectionObj=session.GetHttpConnection();
//后面这2个函数一起作用用于打开服务器上面的文件或者本地的文件
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, pszFileName);
pFile->SendRequest();
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。