使用TIdHTTP控件
try
IdHTTP.Head(URL);
except
showmessage('未连接到Internet或者文件不存在!');
end;
ajax很快。
知道怎么用不?
var xmlhttp:olevariant;
xmlhttp:=createoleobject('Microsoft.XMLHTTP');
xmlhttp.open('GET','地址',false);
xmlhttp.send(nil);
然后判断返回值就可以了
hg:thttpget;
begin
hg:=thttpget.Create(self);
hg.BinaryData:=true;
hg.UseCache:=false;
hg.FileName:='文件名';
hg.URL:=‘网址’;
hg.OnProgress:=onp;
hg.OnDoneFile:=ond;
hg.GetFile;
end;
procedure TForm1.ond(Sender: TObject; FileName: string; FileSize: Integer);
begin
pb.Position:=0;
if fileexists(getcurrentdir+'\Upx.zip')=false then
showmessage('不存在')
end;
这个检测很快,如果你下载的文件不存在,5秒左右就检测出来了。如果存在就会下载下来的。