1、利用函数 :
unitdownloadTest;
interface
uses
Windows,Messages,SysUtils,Variantsdelphi下载文件,Classes,Graphics,Controls,Forms,
Dialogs,StdCtrls,UrlMon;
type
TForm1=class(TForm)
Button1:TButton;
procedureButton1Click(Sender:TObject);
private
{Privatedeclarations}
public
{Publicdeclarations}
end;
var
Form1:TForm1;
implementation
{$R*.dfm}
//文件下载
functionDownloadFile(Source,Dest:string):Boolean;
begin
try
Result:=UrlDownloadToFile(nil,PChar(source),PChar(Dest),0,nil)=0;
except
Result:=False;
end;
end;
procedureTForm1.Button1Click(Sender:TObject);
varfiledir,downloadUrl:string;
begin
filedir:='D:\delphi\download\client.zip';
para=izone&pt_qr_app=手机qq空间&pt_qr_link=http://z.qzone.com/download.html&self_regurl=http://qzs.qq.com/qzone/v6/reg/index.html&pt_qr_help_link=http://z.qzone.com/download.htmllogin_sig=,login_sig:"vvv.qqydw.com&u1=http://qzs.qq.com/qzone/v5/loginsucc.html。http://dg.chinawj.com.cn/product/173069267.html http://nyhb.chinawj.com.cn/gongying/172889313.html http://tools.chinawj.com.cn/product/172887757.html http://suliao.chinawj.com.cn/product/172970767.html。displaylang=zh-cn&familyid=bc327d94-4f2c-481f-8595-fa5b90b11bfc" target="_blank">http.com/download/4/1/8/418981a4-6ef9-4de6-befc-1a53e886cb62/ie7-windowsxp-x86-chs:http.microsoft.aspx.com/downloads/detailsxp sp2://download.microsoft.microsoft://download://www.com/downloads/details:。
ifDownloadFile(downloadUrl,filedir)then
showMessage('文件下载成功')
else
showMessage('文件下载失败');
end;
end.
2、用IdHTTP控件吧!
var
DownLoadFile:TFileStream;
beginio
DownLoadFile:=TFileStream.Create('c:\aa.rar'delphi下载文件,fmCreate);
idhttp1.get(''http://www.sina.com.cn/download/aa.rar'',downloadfile)。oo.href = ['http://baidu.com','http://www.cnblogs.com','http://www.sina.com','http://www.hao123.com','http://www.taobao.com']。console.trace()at c (http://www.contoso.com/trace.html:24:3)at a (http://www.contoso.com/trace.html:18:3)at global code (http://www.contoso.com/trace.html:30:1)console.trace()at c (http://www.contoso.com/trace.html:24:3)at b (http://www.contoso.com/trace.html:21:3)at d (http://www.contoso.com/trace.html:27:3)at global code (http://www.contoso.com/trace.html:31:1)。
DownLoadFile.Free;
end;
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-112343-1.html
没真正打过不知道自己有多少毛病
人
派军舰无害通过钓鱼岛12海里之内
加表情什么鬼