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;
if DownloadFile(http://www.borland.com/delphi6.zip, c:\kylix.zip) then
ShowMessage(Download succesful)
else ShowMessage(Download unsuccesful)
2.
var
DownLoadFile:TFileStream;
beginio
DownLoadFile:=TFileStream.Create(c:\aa.rar,fmCreate);
IdHTTP1.Get(http://www.sina.com.cn/download/aa.rar,DownLoadFile);
DownLoadFile.Free;
end;
//---------------------------
3.
procedure TForm1.Button3Click(Sender: TObject);
var
h:TIdhttp;
res : String;
MyStream:TMemoryStream;
begin
MyStream:=TMemoryStream.Create;
h:=Tidhttp.Create(nil);
try
h.get('http://www.oro.com/project2.exe',MyStream);
except
showmessage('网络出错!');
MyStream.Free;
exit;
end;
MyStream.SaveToFile('c:/1.exe');
MyStream.Free;
end;
本文来自博客园,作者:del88,转载请注明原文链接:https://www.cnblogs.com/del88/archive/2012/02/17/2356044.html