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 只用一条语句就能使tbitmap反色

Delphi 锁定系统解锁系统

Delphi 把流中的字符串转换为 utf 格式

Delphi 中 16 进制转换为 10 进制

Delphi md5单元文件

Delphi 获取当前系统语言环境(en,fr,ja等)

Delphi 获取邮箱中的用户名

Delphi窗口显示和关闭的时候出现动画效果

Delphi 用内存流文件流资源生成客户端

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



打赏

取消

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

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

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

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

评论

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