--- dao/DelphiScanner/Utils.pas 2015/09/03 14:27:21 2693 +++ dao/DelphiScanner/Utils.pas 2015/09/03 14:31:39 2694 @@ -24,6 +24,8 @@ class function Sto_GetFmtFileVersion(const FileName: String = ''): String; + class function CheckUrl(url:string): boolean; + @@ -36,7 +38,8 @@ Windows, Messages, SysUtils, //IntToStr etc - Registry + Registry, + wininet //CheckUrl ; @@ -236,4 +239,43 @@ end; +class function TUtils.CheckUrl(url:string):boolean; +var + hSession, hfile: hInternet; + dwindex,dwcodelen :dword; + dwcode:array[1..20] of char; + res : pchar; +begin + if pos('http://',lowercase(url))=0 then + url := 'http://'+url; + 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 ='302'); + if assigned(hfile) then + InternetCloseHandle(hfile); + InternetCloseHandle(hsession); + end; + +end; + end.