Chinaunix首页 | 论坛 | 博客
  • 博客访问: 578347
  • 博文数量: 752
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:47
文章分类

全部博文(752)

文章存档

2011年(1)

2008年(751)

我的朋友

分类:

2008-10-13 16:51:20

BOOL COpenSourceHTMLDlg::OpenSourceHTML()
{
 UpdateData(TRUE);
 CInternetSession session;
 CInternetFile* file = NULL;
 try
 {
  // 试着连接到指定URL
  file = (CInternetFile*) session.OpenURL(m_strNetAddr);
 }
 catch (CInternetException* m_pException)
 {
  // 如果有错误的话,置文件为空
  file = NULL;
  m_pException->Delete();
  return FALSE;
 }
 
 CString strTempLineInf;
 m_strSourceHtml = "";
 if (file)
 {
  // 读写网页文件,直到为空
  while (file->ReadString(strTempLineInf) != NULL) //如果采用LPTSTR类型,读取最大个数nMax置0,使它遇空字符时结束
  {
   m_strSourceHtml += strTempLineInf;
   m_strSourceHtml += "\r\n";
  }
  file->Close();
  delete file;
 }
 else
 {
  m_strSourceHtml += _T("到指定服务器的连接建立失败..."); 
  return FALSE;
 }

 UpdateData(FALSE);
 return TRUE;
}


--------------------next---------------------

阅读(280) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~