function TForm1.DownloadFile
(const fileURL, FileName: String): boolean;
const BufferSize = 1024;
var
hSession, hURL: HInternet;
Buffer: array[1..BufferSize] of Byte;
BufferLen: DWORD;
f: File;
sAppName: string;
begin
Result:=False;
sAppName := ExtractFileName(Application.ExeName);
hSession := InternetOpen(PChar(sAppName),
INTERNET_OPEN_TYPE_PRECONFIG,
nil, nil, 0);
try
hURL := InternetOpenURL(hSession,
PChar(fileURL),
nil,0,0,0);
try
AssignFile(f, FileName);
Rewrite(f,1);
Gauge1.MaxValue:=BufferLen;
repeat
InternetReadFile(hURL, @Buffer,
SizeOf(Buffer), BufferLen);
BlockWrite(f, Buffer, BufferLen);
Gauge1.Progress:=Gauge1.Progress+1;
until BufferLen = 0;
CloseFile(f);
Result:=True;
finally
InternetCloseHandle(hURL)
end
finally
InternetCloseHandle(hSession)
end
end;
naisao sam na ovaj cod kada sam trazio neshto sto ce mi omoguciti download nekog filea sa interneta a da pritom mogu prikaziti progress tog downloadovanja u nekom progressbaru. problem je u tome sto se pri startovanju funkcije program zaledi do zavrsetka downloada. Da li neko zna u cemu je problem?