Delphi’de hazır olarak gelmekte olan TDownloadURL adlı bir Action var. Bu Action internetten dosya indirme islemini cok kolaylastiriyor. Download islemi sirasinda meydana gelen her turlu olayi isleyebilmemiz icin bize OnDownloadProgess adli bir olay sunuyor. Biz simdi bu olayi kullanarak internetten dosya indirirken o ana kadar inen byte miktarini hem title da hem de bir progressbar uzerinde gosterecez.
Ilgili actionu kullanabilmek icin uses satirina ExtActns unitini ekleyelim.
Formun public alanina asagida ki sekilde bir procedure tanimlayalim. Bu TDownloadUrl nesnemizin OnDownloadProgress olayina atayacagimiz metodumuz.
Public
procedure URL_OnDownloadProgress(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String; var Cancel: Boolean) ;
bu da ilgili metodun govdesi.
procedure TForm17.URL_OnDownloadProgress(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String; var Cancel: Boolean);
begin
ProgressBar1.Max:= ProgressMax;
ProgressBar1.Position:= Progress;
Application.ProcessMessages;
Caption := FormatFloat('#,###',Progress) + ' byte / ' + FormatFloat('#,###',ProgressMax) + ' byte';
end;
Metod bize cok sayida parametre veriyor. Bu paremetleri kullanarak bir cok islem yapmak mumkun ama biz simdilik sadece Progress ve ProgressMAx parametrelerini kullanacaz.
Progress = o ana kadar inen byte miktari
ProgressMax = dosyanin toplam byte cinsinden boyutu
bu da TDownloadUrl nesnemizi calistiran dugmenin kodu.
procedure TForm17.Button1Click(Sender: TObject);
begin
with TDownloadURL.Create(self) do
try
URL:=edit1.Text;
FileName := 'inendosya.exe';
OnDownloadProgress := URL_OnDownloadProgress;
ExecuteTarget(nil);
finally
Free;
end;
end;

Entries (RSS)
May 20th, 2006 at 12:55:00
Eline sağlık güzel bir tip.
May 23rd, 2006 at 09:55:22
Bu çok iyi bir tip olacak. Tam da işime yarayacağı günde ilaç gibi geldi.
July 27th, 2006 at 04:10:07
I must do this proggramm. But EXTACTNS is not available in my computer. I use Delphi5. Perhaps You give me wrong code. Everybody is always doing like this. wrong codes, missing codes. You are one of them. AGAIN:
I CANT download file FROM INTERNET…
July 29th, 2006 at 03:42:56
This code works fine. I’ve tested it.
October 31st, 2008 at 04:27:02
çok teşekkurler geyte guzel calişiyor