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 tlist性能注意事项

Delphi操作excel说明

Delphi实现屏幕截图、窗口截图、指定区域截图

Delphi利用getprocessmemoryinfo获取进程占用内存大小

Delphi vista以上系统的进程静音

Delphi中如何提高listview删除item的速度

Delphi 字符串加单引号

Delphi 掌控pagecontrol中的右上方的左右箭头事件

Delphi 改变进程优先级

Delphi完美的线程注入和卸载

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



打赏

取消

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

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

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

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

评论

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