CInternetSession  多线程 好像最多支持4个线程,多了就不行了!!
高手帮忙,就只60分了。CString StrURL=url;  //被下载的地址
CString StrMsg="";

CInternetFile* MyFile = NULL;
    CInternetSession* MySession=new CInternetSession("xxxxx",NULL);
int isUTF8=0;
 int isConvert=0;
/* 
网络连接请求时间超时值在数毫秒级。如果连接请求时间超过这个超时值,请求将被取消。 
缺省的超时值是无限的。 
*/ 
MySession->SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,6000);
MySession->SetOption(INTERNET_OPTION_SEND_TIMEOUT,60000);
MySession->SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT,60000);
/* 在重试连接之间的等待的延时值在毫秒级。*/ 
MySession->SetOption(INTERNET_OPTION_CONNECT_BACKOFF,500); 
/* 在网络连接请求时的重试次数。如果一个连接企图在指定的重试次数后仍失败,则请求被取消。 缺省值为5。*/ 
MySession->SetOption(INTERNET_OPTION_CONNECT_RETRIES, 2);
try
{
  MyFile=(CInternetFile*)MySession->OpenURL(StrURL); //关键
}
catch(CException *ex) 

  MyFile = NULL;
 // pEx->Delete();
}
try
{
if (MyFile)
{
 
if(MyFile->GetLength()<2) return "";
//如果文件大于1024KB就返回
CString   Filesize;   
if( ((CHttpFile *)MyFile)->QueryInfo(HTTP_QUERY_CONTENT_LENGTH,Filesize))
{
int iTotolPos=atoi(Filesize);   
if(iTotolPos>1048576)
{
return "";
}
}
else
{
return "";
}
//返回状态
  DWORD   dwStatusCode; 
if( ((CHttpFile *)MyFile)->QueryInfoStatusCode(dwStatusCode))

if(dwStatusCode==400)
{
//AfxMessageBox("400");
return "";
}
}
else
{
return "";
}
  CString StrLine;
long Num_Line=1;
while (MyFile->ReadString(StrLine)!=NULL)
{

   if(Num_Line % 300) Sleep(1);
   StrMsg += StrLine + "\r\n"; //换行处理
   Num_Line=Num_Line+1;
}
}

else
{
return "";

 
}
  catch(CException *ex) 

}
    MyFile->Close();
    delete MyFile;
 
return StrMsg;