Delphi ICS multi-threaded download

Source: Internet
Author: User

First, the Fmultiparthttp event:

Download Complete Event

Httprequestdone (Sender:tobject; Errorcode:integer; Const reason:string);

Release the downloaded file stream here

FMultiPartHTTP.FileStream.Free;

Fmultiparthttp.filestream: = nil;

Second, download display status information events

Httpshowstats (Sender:tobject);

Display the current download status here

str: = ' downloaded (MB): ' + Format ('%2f ', [fmultiparthttp.totalcount/1024/1024]) +

' percent complete: ' + Format ('%3.0f ', [fmultiparthttp.percentdone]) + '% ' +

' Download speed (kb/seconds): ' + Format ('%6.2f ', [fmultiparthttp.curspeed]) +

' Time consuming: ' + formatdatetime (' Hh:nn:ss ', fmultiparthttp.elapsedtime);

Iii. events related to the ICS progress bar

The following 2 events and progress bar, ICS comes with a download progress bar

Httpprogressaddsegment (Sender:tobject; Startoffset, Aspan, Initpos:int64);

Aspan segment size, initpos segment start size, Startoffset, segment start size

Httpprogresssetposition (Sender:tobject;index:integer; Position:int64);

Index number of segments Position the size of the downloaded fragment

Iv. Examples of usage:

fmultiparthttp.url:= download file address;

fmultiparthttp.partcount:= number of blocks;

Fmultiparthttp.filestream:=tfilestream.create (' download local filename ', fmcreate);

Fmultiparthttp.start;




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.