在VS中关于使用CInternetSession 获取网页的问题,为什么我最后读取了内容少了一些字符
     如打开http://www.baidu.com/时最后显示的前面一些字符为<dcyehm>hm>ha>mt tpeuv"otn-ye otn=tx/tlcastg21"<il>偃宦酮?  /il>syebd{ot1p }k,s{etclainmdl}l{agn3p }l pnfn:4x"五}l{................
     实际应为<!doctype html><html><head><meta http-equiv="Content-Type" co  ntent="text/html;charset=gb2312"><title>百度一下,你就知道................显然是恰好是每两个字符中少了一个我用的代码如下:void CConnectLastDlg::OnClick()
{
 CString m_Url=_T("http://www.baidu.com/");
 CString m_Text=_T("");
 //GetDlgItem(IDC_URL)->GetWindowText(m_Url);
 ///////////////
 // TODO: Add your control notification handler code here
 CInternetSession httpsession;      //定义网络连接Session
 CString Line;
 CInternetFile * webfile=NULL;      //定义一个文件对象指针
 UpdateData();      
 if(m_Url.Left(7)!= _T("http://")) //如果地址不含HTTP类型标志则添加本地文件类型标志
 {
    m_Url=_T("http://") + m_Url;
 }
 try
 {
  webfile=(CInternetFile*)httpsession.OpenURL(m_Url);//打开连接
 }
 catch(CInternetException*pException)     //捕捉异常
 {
  MessageBox (L"wrong");
  webfile=NULL;
  pException->Delete();
  }
 if(webfile)
 {
  int i=0;
  CString kongge(_T("\r\n"));
  bool mybool=webfile->ReadString(Line);
  m_Text.Empty ();
  while(mybool && i<2)/    /读出几行
  {
   m_Text=m_Text+Line+kongge;    //加入换行标志
   i++;
   mybool=webfile->ReadString(Line);  }
 }
 else {
    MessageBox (L"NULL"); } StringPro* myPro=new StringPro;//辅助函数类,进行编码转换
 myPro->CSrChangeToUn( m_Text);//在后面列出
 TOSHOWSTR=m_Text; UpdateData(FALSE);         //更新显示文件
 delete webfile;          //删除文件
 //GetDlgItem (IDC_SHOW)->EnableWindow (FALSE);  //禁用显示按钮
 httpsession.Close();  
} void StringPro::CSrChangeToUn(CString &str)//当用CString直接读取ANSI文本数据时如何再次转换为UNICODE
{ char *szBuf = new char[str.GetLength()];
 for (int i = 0 ; i < str.GetLength(); i++)
 {
 szBuf[i] = str.GetAt(i);
 }
 CharToUnicode(szBuf , &str);
 delete []szBuf;
}// 将Char型字符转换为Unicode字符
int StringPro::CharToUnicode(char *pchIn, CString *pstrOut)
{
 int nLen;
 WCHAR *ptch;
 if(pchIn == NULL)
 {
 return 0;
 }
 nLen = MultiByteToWideChar(CP_ACP, 0, pchIn, -1, NULL, 0);
 ptch = new WCHAR[nLen+1];
 MultiByteToWideChar(CP_ACP, 0, pchIn, -1, ptch, nLen);
 ptch[nLen] = '\0'; pstrOut->Format(_T("%s"), ptch);
 
delete [] ptch;
 return nLen;