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;