/[projects]/dao/DelphiScanner/Utils.pas
ViewVC logotype

Diff of /dao/DelphiScanner/Utils.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2693 by torben, Thu Sep 3 14:27:21 2015 UTC revision 2694 by torben, Thu Sep 3 14:31:39 2015 UTC
# Line 24  type Line 24  type
24    
25      class function Sto_GetFmtFileVersion(const FileName: String = ''): String;      class function Sto_GetFmtFileVersion(const FileName: String = ''): String;
26    
27        class function CheckUrl(url:string): boolean;
28    
29    
30    
31    
# Line 36  uses StrUtils, Line 38  uses StrUtils,
38    Windows,    Windows,
39    Messages,    Messages,
40    SysUtils, //IntToStr etc    SysUtils, //IntToStr etc
41    Registry    Registry,
42      wininet   //CheckUrl
43    
44    ;    ;
45    
# Line 236  begin Line 239  begin
239  end;  end;
240    
241    
242    class function TUtils.CheckUrl(url:string):boolean;
243    var
244      hSession, hfile: hInternet;
245      dwindex,dwcodelen :dword;
246      dwcode:array[1..20] of char;
247      res : pchar;
248    begin
249      if pos('http://',lowercase(url))=0 then
250        url := 'http://'+url;
251      Result := false;
252      hSession := InternetOpen('InetURL:/1.0',
253                                INTERNET_OPEN_TYPE_PRECONFIG,
254                                nil,
255                                nil,
256                                0);
257      if assigned(hsession) then
258      begin
259        hfile := InternetOpenUrl(hsession,
260                                 pchar(url),
261                                 nil,
262                                 0,
263                                 INTERNET_FLAG_RELOAD,
264                                 0);
265        dwIndex := 0;
266        dwCodeLen := 10;
267        HttpQueryInfo(hfile,
268                      HTTP_QUERY_STATUS_CODE,
269                      @dwcode,
270                      dwcodeLen,
271                      dwIndex);
272        res := pchar(@dwcode);
273        result:= (res ='200') or (res ='302');
274        if assigned(hfile) then
275          InternetCloseHandle(hfile);
276        InternetCloseHandle(hsession);
277      end;
278    
279    end;
280    
281  end.  end.

Legend:
Removed from v.2693  
changed lines
  Added in v.2694

  ViewVC Help
Powered by ViewVC 1.1.20