www.pudn.com > MyInternet.rar > MyWinInetClass.cpp


// MyWinInetClass.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "MyInternet.h" 
#include "MyWinInetClass.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CMyWinInetClass dialog 
 
/* 
CMyWinInetClass::CMyWinInetClass(CWnd* pParent NULL*//*=) 
	: CDialog(CMyWinInetClass::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CMyWinInetClass) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
*/ 
/* 
void CMyWinInetClass::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CMyWinInetClass) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
*/ 
 
CMyWinInetClass::CMyWinInetClass() 
{ 
} 
 
CMyWinInetClass::~CMyWinInetClass() 
{ 
} 
 
 
#if 0 
BEGIN_MESSAGE_MAP(CMyWinInetClass, CHttpServer);//CDialog) 
	//{{AFX_MSG_MAP(CMyWinInetClass) 
		// NOTE: the ClassWizard will add message map macros here 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CMyWinInetClass message handlers 
 
CString CMyWinInetClass::ConnectHttp(const CString sUrl) 
{ 
	CString sResult; 
	CInternetFile *hHttpFile=NULL; 
 
	sResult=""; 
	sResult=sResult+"Trying to connect Http sites "+sUrl+"\r\n"; 
 
	hHttpFile=(CInternetFile *)m_session.OpenURL(sUrl);	//得到文件指针 
 
	if(hHttpFile) 
	{ 
		sResult=sResult+"Connection established.\r\n"; 
		CString sLine; 
		while(hHttpFile->ReadString(sLine))		//读取Http服务器上的内容 
		{ 
			sResult=sResult+sLine+"\r\n"; 
		} 
		hHttpFile->Close();			//关闭连接 
	} 
	else 
	{ 
		sResult=sResult+"There are some errors in finding this Http sites"; 
	} 
	return sResult; 
}