比如检测到
http://192.168.1.10/check.txt 存在时,返回值则为true

解决方案 »

  1.   

    function  CheckURL(url:string):Boolean;
     var
     hSession,hfile,hRequest:hInternet;
     dwIndex,dwCodelen:dword;
     dwcode:array[1..20] of char;
     res:pchar;
     begin
      result:=false;
      hsession:=Internetopen('inetURL:/1.0',INTERNET_OPEN_TYPE_PRECONFIG,nil,nil,0);
      if assigned(hsession) then
      begin
       hfile:=InternetopenURL(hsession,pchar(url),nil,0,INTERNET_FLAG_RELOAD,0);
       dwIndex:=0;
       dwCodelen:=10;
       httpQueryInfo(hfile,HTTP_QUERY_STATUS_CODE,@dwCode,dwCodelen,dwIndex);
       res:=pchar(@dwcode);
       result:=(res='200') or(res='320');
       if assigned(hfile) then
       INternetclosehandle(hfile);
       internetclosehandle(hsession);
       end;
      end;例如:
    CheckURL('http://www.zju.edu.cn/xyy/iloveyou.txt');
      

  2.   

    必须现要保证网络是连通的,Enjoy it!