FTP下载: http://www.7880.com/Info/Article-19938be0.html
http://community.csdn.net/Expert/topic/3300/3300012.xml?temp=5.028933E-02
FTP下载: TIdFTP控件 (Delphi7 Indy)
Http下载: (Delphi7)使用设计Indy控件下载网络文件 //////////
在Form1中添加控件:
两个Indy控件:IdAntiFreeze1,IdHTTP1;
一个按钮 :Button1;
一个进度条 :ProgressBar1 显示下载速度
procedure TForm1.Button1Click(Sender: TObject);
var
MyStream:TMemoryStream;
begin
IdAntiFreeze1.OnlyWhenIdle:=False;//设置使程序有反应.
MyStream:=TMemoryStream.Create;
try
IdHTTP1.Get('http://www.appcontrols.com/demos/exe/HTTPDemo.exe',MyStream);
except
Showmessage('没有下载成功!');
MyStream.Free;
Exit;
end;
MyStream.SaveToFile(ExtractFilePath(paramstr(0))+'HTTPDemo.zip');
MyStream.Free;
Showmessage('OK');
end;
procedure TForm1.IdHTTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
//开始下载前,将ProgressBar1的最大值设置为需要接收的数据大小.
ProgressBar1.Max:=AWorkCountMax;
ProgressBar1.Min:=0;
ProgressBar1.Position:=0;
end;
procedure TForm1.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
//接收数据的时候,进度将在ProgressBar1显示出来.
ProgressBar1.Position:=ProgressBar1.Position+AWorkCount;
end;
本文地址:http://com.8s8s.com/it/it4780.htm