zoukankan      html  css  js  c++  java
  • 一段下载文件的源码

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ExtActns, ComCtrls;

    type
    TForm1 = class(TForm)
    ProgressBar1: TProgressBar;
    Label1: TLabel;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
    DownLoadURL : TDownLoadURL;
    procedure DownloadProgress(Sender: TDownLoadURL; Progress,
    ProgressMax: Cardinal; StatusCode: TURLDownloadStatus; StatusText: String;
    var Cancel: Boolean);
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.DownloadProgress(Sender: TDownLoadURL; Progress,
    ProgressMax: Cardinal; StatusCode: TURLDownloadStatus;
    StatusText: String; var Cancel: Boolean);
    begin
    Label1.Caption := StatusText;
    ProgressBar1.Max := ProgressMax;
    ProgressBar1.Position := Progress;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    DownLoadURL := TDownLoadURL.Create(self);
    with DownLoadURL do
    begin
    FileName := 'c:p.exe';
    URL := 'http://www.teechart.net/files/vcl/public/TeeChartPro6/TeeChart601Delphi6_RTL3.EXE';
    OnDownloadProgress := DownloadProgress;
    end;
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    DownLoadURL.ExecuteTarget(DownLoadURL);
    end;

  • 相关阅读:
    第一个WPF
    redis pub/sub 发布订阅
    php中header函数后是否应该有exit
    redis的图形界面管理工具
    redis key和value数据类型
    螺旋式打印一个二维数组
    jquery 提示插件 cluetip
    php异常处理
    ruby Methods, Procs, Lambdas, and Closures
    ruby迭代器iterator和枚举器Enumerator
  • 原文地址:https://www.cnblogs.com/onionhacker/p/3527192.html
Copyright © 2011-2022 走看看