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;




posted on 2012-02-17 16:49  del88  阅读(6)  评论(0编辑  收藏  举报