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 选择目录对话框(selectdirectory 函数)

Delphi写游戏外挂

Delphi firedac sqlite不能插入"&"符号

Delphi for xx in xx do 语法的使用示例

Delphi 三个消息函数的威力

Delphi 修改窗口标题

Delphi中禁用和取消android应用睡眠

Delphi 的字符串在 firemonkey 模式下

Delphi 获取计算机名和用户名

Delphi编辑环境

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



打赏

取消

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

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

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

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

评论

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