W
wtzwtz
Unregistered / Unconfirmed
GUEST, unregistred user!
用如下函数下载网络文件,如果网络不通或连接速度很慢,程序就有一段时间失去响应。请问该如何使程序有响应,并通过停止按钮,结束下载啊?另外如果要下载两个或更多文件,该如何修改啊?
uses
UrlMon;
function DownloadFile(Source, Dest: string): Boolean;
begin
try
Result := UrlDownloadToFile(nil, PChar(source), PChar(Dest), 0, nil) = 0;
except
Result := False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DownloadFile('http://image2.sina.com.cn/ty/up/2005-12-27/U1158P6T64D16292F1091DT20051227033029.jpg', 'd:/812812.jpg');
end;
uses
UrlMon;
function DownloadFile(Source, Dest: string): Boolean;
begin
try
Result := UrlDownloadToFile(nil, PChar(source), PChar(Dest), 0, nil) = 0;
except
Result := False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DownloadFile('http://image2.sina.com.cn/ty/up/2005-12-27/U1158P6T64D16292F1091DT20051227033029.jpg', 'd:/812812.jpg');
end;