首页 > 其他 > 详细

一段下载文件的源码

时间:2014-01-21 16:30:45      阅读:284      评论:0      收藏:0      [点我收藏+]

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;

一段下载文件的源码

原文:http://www.cnblogs.com/onionhacker/p/3527192.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!