• 大小: 1.56MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-31
  • 语言: C/C++
  • 标签: libcurl  download  

资源简介

vc++使用libcurl下载文件,支持断点续传,支持多文件下载;代码经测试,可以编译运行;使用url解析文件名;谢谢支持!

资源截图

代码片段和文件信息

// LibcurlTest.cpp : 定义控制台应用程序的入口点。
//

#include “stdafx.h“
#include 
#include 
#include “TinyDownload.h“

/*#include “ProcessCommunicate.h“*/
DWORD WINAPI ShowDownloadProcess(LPVOID);
int main(void)
{
DWORD tick = GetTickCount();
CTinyDownload murl;
DLIO mDlWork;
strcpy(mDlWork.url“http://g.hiphotos.baidu.com/album/h%3D900%3Bcrop%3D0%2C0%2C1440%2C900/sign=6efd8163faf2b211fb2e894efabb064a/d8f9d72a6059252daaeffa14359b033b5bb5b922.jpg“);
strcpy(mDlWork.filePath “d:\\Download\\image\\32.jpg“);
murl.AddDownloadWork(mDlWork);

strcpy(mDlWork.url“http://image.baidu.com/channel/listdownload?word=download&ie=utf8&countop=0&fr=detail&url=http://e.hiphotos.baidu.com/album/w%3D2048/sign=2033f8933b292df597c3ab1588095e60/a686c9177f3e67097de078433ac79f3df9dc55ad.jpg&col=美女&image_id=6644358580&tag=可爱“);
strcpy(mDlWork.filePath “.\\Download\\image\\2.jpg“);
murl.AddDownloadWork(mDlWork);

strcpy(mDlWork.url“http://d.hiphotos.baidu.com/album/h%3D900%3Bcrop%3D0%2C0%2C1440%2C900/sign=ff23684600e939014902813e4bd73795/b17eca8065380cd712d9728ba044ad3458828195.jpg“);
strcpy(mDlWork.filePath “.\\Download\\image\\3.jpg“);
murl.AddDownloadWork(mDlWork);

strcpy(mDlWork.url“http://e.hiphotos.baidu.com/album/h%3D900%3Bcrop%3D0%2C0%2C1440%2C900/sign=ba77c3185243fbf2da2caa238045a9f2/500fd9f9d72a60595906070a2934349b033bba88.jpg“);
strcpy(mDlWork.filePath “.\\Download\\image\\4.jpg“);
murl.AddDownloadWork(mDlWork);

strcpy(mDlWork.url“http://e.hiphotos.baidu.com/album/h%3D900%3Bcrop%3D0%2C0%2C1440%2C900/sign=c822e5f12e2eb938f36d76f2e559e647/ac345982b2b7d0a29031e28dcaef76094b369a22.jpg“);
strcpy(mDlWork.filePath “.\\Download\\image\\5.jpg“);
murl.AddDownloadWork(mDlWork);

strcpy(mDlWork.url “http://ardownload.adobe.com/pub/adobe/reader/win/11.x/11.0.01/en_US/AdbeRdr11001_en_US.exe“);
strcpy(mDlWork.filePath “.\\Download\\“);
murl.AddDownloadWork(mDlWork);

murl.StartDownloadThread();
CURDI curInfo;
double curDownloadLenpreLen = 0.0;
while(1)
{
if(murl.IsDownloadBegin())
{
murl.GetCurrentDownloadInfo(&curInfo);
curDownloadLen = curInfo.CurDownloadLen;
printf(“正在下载:%s下载进度:%6.2lf%%下载速度:%9.2lfKB/s\r“curInfo.fileName
((double)curInfo.preLocalLen+curInfo.CurDownloadLen)/curInfo.totalFileLen*100(curDownloadLen-preLen)/(double)(GetTickCount()-tick));
tick = GetTickCount();
Sleep(500);
}
if(murl.IsDownloadEnd()) break;
preLen = curDownloadLen;
}
return 0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-08-09 16:42  LibcurlForDownload\
     目录           0  2013-08-09 16:41  LibcurlForDownload\Debug\
     文件      822272  2013-08-09 16:41  LibcurlForDownload\Debug\LibcurlTest.pdb
     目录           0  2013-08-09 16:30  LibcurlForDownload\include\
     目录           0  2013-08-09 16:30  LibcurlForDownload\include\curl\
     文件       83897  2013-06-28 19:17  LibcurlForDownload\include\curl\curl.h
     文件       22273  2013-06-22 11:32  LibcurlForDownload\include\curl\curlbuild.h
     文件        6913  2012-12-11 23:32  LibcurlForDownload\include\curl\curlbuild.h.cmake
     文件        7143  2013-06-22 00:29  LibcurlForDownload\include\curl\curlbuild.h.in
     文件        8934  2013-06-22 00:29  LibcurlForDownload\include\curl\curlrules.h
     文件        2741  2013-06-22 11:32  LibcurlForDownload\include\curl\curlver.h
     文件        3472  2012-12-11 23:32  LibcurlForDownload\include\curl\easy.h
     文件        2181  2012-12-11 23:32  LibcurlForDownload\include\curl\Makefile.am
     文件       21779  2013-06-22 00:29  LibcurlForDownload\include\curl\Makefile.in
     文件        2788  2013-06-22 00:29  LibcurlForDownload\include\curl\mprintf.h
     文件       14672  2013-06-22 00:29  LibcurlForDownload\include\curl\multi.h
     文件        1330  2012-12-11 23:32  LibcurlForDownload\include\curl\stdcheaders.h
     文件       36918  2013-06-22 00:29  LibcurlForDownload\include\curl\typecheck-gcc.h
     目录           0  2013-08-09 16:41  LibcurlForDownload\ipch\
     目录           0  2013-08-09 16:41  LibcurlForDownload\ipch\libcurltest-d929b706\
     文件     2621440  2013-08-09 16:41  LibcurlForDownload\ipch\libcurltest-d929b706\libcurltest-16ad2ff9.ipch
     目录           0  2013-08-09 16:30  LibcurlForDownload\lib\
     文件       13966  2013-07-18 12:20  LibcurlForDownload\lib\libcurld_imp.lib
     文件         900  2013-08-09 16:33  LibcurlForDownload\LibcurlForDownload.sln
     文件       11776  2013-08-09 16:42  LibcurlForDownload\LibcurlForDownload.suo
     目录           0  2013-08-09 16:41  LibcurlForDownload\LibcurlTest\
     目录           0  2013-08-09 16:41  LibcurlForDownload\LibcurlTest\Debug\
     文件        2878  2013-08-09 16:41  LibcurlForDownload\LibcurlTest\Debug\cl.command.1.tlog
     文件       44356  2013-08-09 16:41  LibcurlForDownload\LibcurlTest\Debug\CL.read.1.tlog
     文件        2418  2013-08-09 16:41  LibcurlForDownload\LibcurlTest\Debug\CL.write.1.tlog
     文件          93  2013-08-09 16:41  LibcurlForDownload\LibcurlTest\Debug\LibcurlTest.Build.CppClean.log
............此处省略41个文件信息

评论

共有 条评论