[原]从获得下载地址,到下载至本地磁盘

2008-12-12

void DownFile(CString url)

{

int lost=url.ReverseFind(‘/’);

CString fileName=url.Right(url.GetLength()-lost-1); //得到需要下载的程序名称

CString filePath=””;

filePath.Format(“d:\%s”,fileName);

URLDownloadToFile(NULL,url,filePath,NULL,NULL);

}

DWORD WINAPI DownNewFile(PVOID p)

{

CInternetSession cs(NULL,NULL);

CHttpFile *pFile;

CString fileData=””;

pFile=(CHttpFile*)cs.OpenURL(“”);

while (pFile->ReadString(fileData))

{

   DownFile(fileData);

}

return 1;

}

代码简介易懂.. 不做详解…