if(((CHttpFile*)mySession.OpenURL(dest))==NULL)连续运行几次后,程序就不能运行
debug下连续运行几次后,debug就不能进入该语句且不能跳过该语句
大家遇见过这样的情况吗

解决方案 »

  1.   

    可以用下面的方法试试:
    CString m_szSite="http://localhost";
    CString m_szResult;
    if(m_szSite.Left(7)!="http://")
    {
    AfxMessageBox("HTTP site needed!");
    return;
    }
    m_szResult.Empty();
    m_szResult+="Please wait while trying to open "+m_szSite+"\r\n";
    UpdateData(FALSE); CInternetSession session;
    CHttpFile* pFile=NULL;
    try
    {
    pFile=(CHttpFile*)session.OpenURL(m_szSite);
    }
    catch(CInternetException* pEx)
    {
    pFile=NULL;
    pEx->Delete();
    } if(pFile)
    {
    m_szResult+="OK!HTTP Site found!\r\n";
    m_szResult+="----------------------\r\n";
    CString szLine;
    while(pFile->ReadString(szLine))
    {
    m_szResult+=szLine+"\r\n";
    }
    pFile->Close();
    delete pFile;
    }
    else
    {
    m_szResult+="Sorry!HTTP Site not found!\r\n";
    } session.Close();