procedure TForm1.Button1Click(Sender: TObject);
function Get(URL,Dest: string): boolean;
var
DownLoadFile:TFileStream;
begin
Result:= False;
DownLoadFile:=TfileStream.Create(dest,fmCreate);
try
try
idhttp1.HandleRedirects:= true; //必须支持重定向否则可能出错
idhttp1.ReadTimeout:= 30000; //超过这个时间则不再访问
IDHTTP1.Get(URL,DownLoadFile);
if IDHTTP1.ResponseCode=200 then
Result :=true;
except
on E: Exception do
Application.MessageBox(pchar('出现异常,操作终止!'+#10#13+E.Message),'提示',mb_ok+mb_iconinformation);
end;
finally
downloadfile.Free;
end;
end;
begin
get('http://www.indyproject.org/downloads/10/indy10.0.52_source.zip','c:/abc.rar');
end;