用有线路由上网时,包含CInternetSession::OpenURL函数的程序可以正常用,
用无线路由上网时,包含CInternetSession::OpenURL函数的程序就失效了,求原因。

解决方案 »

  1.   


    BOOL CHTTPDlg::OpenTheURL()
    {
        CInternetSession httpSession;
        CHttpFile* htmlFile=NULL;
        httpSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,5000);     //设置超时时间 
        httpSession.SetOption(INTERNET_OPTION_CONNECT_RETRIES,20);     //设置重试次数 
        MessageBox("a");
        try
        {
            MessageBox("b");
            htmlFile=(CHttpFile*)httpSession.OpenURL(URLX,1,
       INTERNET_FLAG_TRANSFER_ASCII|INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE);
    //问题出在htmlFile=这一行,无线路由上网时,代码能执行MessageBox("b");,但是不能执行MessageBox("c");,等一段时间后,直接弹出下面的MessageBox("CInternetException");代码
           MessageBox("c");
        }
        catch(CInternetException * m_pException)
        {
            MessageBox("d");
            htmlFile=NULL;
            m_pException->m_dwError;
            m_pException->Delete();
            httpSession.Close();
            MessageBox("CInternetException");
            return false;
        }
    CString content;
    while (htmlFile->ReadString(content))
    {
    all_html+=content+" ";
    }
    htmlFile->Close();
    httpSession.Close();
    return true;
    }
      

  2.   

    第一,我试了一下,把URLX赋值成http://baidu.com是可以访问的,无线路由器的情况下
    第二,既然你说了会跳到异常里面,那就调用m_pException->GetErrorMessage(buf, sizeof(buf));
    来看看错误信息是什么,不就能进一步定位了么