KERNEL32! 7c812afb()
MSVCRTD! _CxxThrowException@8 + 57 bytes
AfxThrowInternetException(unsigned long 1, unsigned long 12002) line 2751
CInternetFile::ReadString(char * 0x044ab8f4, unsigned int 15) line 1178
CInternetFile::ReadString(CString & {"href="http://list.mp3.baidu.com/list/bangping(070208).html" target="_blank">2007-02-08</A><A href="http://list.mmp3.baidu.com/list/bangping(070301).html" target="_blank">2007-03-01</A><A "}) line 1220 + 20 bytes
DownloadFile(void * 0x00f86f08) line 400 + 20 bytes
_AfxThreadEntry(void * 0x0388fd1c) line 112 + 13 bytes
_threadstartex(void * 0x01028100) line 212 + 13 bytes
KERNEL32! 7c80b729()
catch(CInternetException *pEx)
{

if(pServer!=NULL)
{
 pServer->Close();
 delete pServer;
}
   if(pHttpFile!=NULL)
{
  pHttpFile->Close();
  delete pHttpFile;
}
pEx->Delete();
MyConnect.Close();
if (ptr!=NULL)
{
ptr->mm_DownLoadData.DeleThread();
    ptr->AddString(URL+"\r\nDownload failed!\r\n",0);
}
return 0;
}

解决方案 »

  1.   

    [Quote=引用 1 楼 visualeleven 的回复:]你应该贴try里面的东西吧
    [/Quote try
    {
    if (!AfxParseURL(URL, dwServiceType, strServerName, strObject, nPort) ||dwServiceType != INTERNET_SERVICE_HTTP)
    {
    THROW(new CInternetException(dwServiceType));
    }
    pServer=MyConnect.GetHttpConnection(strServerName, nPort);
    if (pServer!=NULL)
    {
    pHttpFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
    strObject, NULL, 1, NULL, NULL);
    if (pHttpFile!=NULL)

    pHttpFile->AddRequestHeaders(_T("Accept: text/*\r\nUser-Agent: MFC\r\n"));
            pHttpFile->SendRequest();
    DWORD StatusCode;
    pHttpFile->QueryInfoStatusCode(StatusCode);
    //file isn't there or is redirected
            if (StatusCode == HTTP_STATUS_MOVED ||StatusCode == HTTP_STATUS_REDIRECT ||StatusCode == HTTP_STATUS_REDIRECT_METHOD)
    {
    CString strNewLocation;
    pHttpFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strNewLocation);

    int nPlace = strNewLocation.Find(_T("Location: "));
    if (nPlace == -1)
    {
    THROW(new CInternetException(StatusCode));
    }
    strNewLocation = strNewLocation.Mid(nPlace + 10);
    nPlace = strNewLocation.Find('\n');
    if (nPlace > 0)
    strNewLocation = strNewLocation.Left(nPlace);

    // close up the redirected site
    pHttpFile->Close();
    delete pHttpFile;
    pServer->Close();
    delete pServer;

    // figure out what the old place was
    if (!AfxParseURL(strNewLocation, dwServiceType, strServerName, strObject, nPort))
    {
    THROW(new CInternetException(StatusCode));
    }

    if (dwServiceType != INTERNET_SERVICE_HTTP)
    {
    THROW(new CInternetException(StatusCode));
    }

    // try again at the new location
    pServer = MyConnect.GetHttpConnection(strServerName, nPort);
    if (pServer!=NULL)
    {
    pHttpFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
        strObject, NULL, 1, NULL, NULL);
    if (pHttpFile!=NULL)

    pHttpFile->AddRequestHeaders(_T("Accept: text/*\r\nUser-Agent: MFC\r\n"));
    pHttpFile->SendRequest();
    pHttpFile->QueryInfoStatusCode(StatusCode);
    }
           
    }

    }
    if (StatusCode != HTTP_STATUS_OK)
    {
    THROW(new CInternetException(StatusCode));
    }
    }
       
    }
    }
    ]