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过滤一段字符里面的html代码的函数

Delphi edit 让密码变成点

Delphi 中打开浏览器跳转网址链接网页的几种方法

Delphi listview1 中添加check选中事件

Delphi 获取网络图片

Delphi 合并两个 wav 文件流的函数

Delphi操作access

Delphi tstringlist 文本文件拼接

Delphi屏蔽win、ctrl_esc、alt_tab、alt_f4等键(windows xp、windows 2003 server下测试通过)

Delphi分离汉字和英文字母

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



打赏

取消

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

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

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

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

评论

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