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;

相关阅读 >>

Delphi文件监视主单元文件

Delphi xe新语法/新功能

Delphi 监控文件系统

Delphi 下的通配符查找函数

Delphi设置光标在edit右边

Delphi jpeg压缩的两种方法

Delphi获取系统特殊文件夹路径

Delphi xe7 新的并行库 system.threading

Delphi 解析系统环境变量

idhttp控件的防止异常的处理

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...