delphi Indy 组件包里的 IDHTTP 组件使用 Get 方法下载文件限速的方法  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi Indy 组件包里的 IDHTTP 组件使用 Get 方法下载文件限速的方法


 

Delphi XE + Indy 10.5.7,限速不是很准确,不过还凑合吧

分别拖一个 idhttp 和 IdInterceptThrottler 组件到窗体,

设置 idhttp 的 IdIntercept 为 IdInterceptThrottler1,然后设置 IdInterceptThrottler1 的属性:


var
  fs: TFileStream;
  i: Integer;
begin

  i := StrToIntDef(Edit3.Text,40);// 40 代表限制的速度
  IdInterceptThrottler1.BitsPerSec := i *1024*10; // 赋给 IdInterceptThrottler1 的属性
  fs := TFileStream.Create(Edit2.Text, fmCreate or fmShareDenyNone);
  try

    IdHTTP1.Get(Edit1.Text, fs);// 下载
  finally
  if
Assigned(fs)then
    fs.Free;
  end;

    Application.ProcessMessages;
end;

。。。哇,凌晨 3 点多了,还是睡觉吧。。

http://hi.baidu.com/sail2000/blog/item/d920b1191d988c5043a9ad8c.html


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.13060617446899 seconds