/[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 2695 by torben, Thu Sep 3 14:40:49 2015 UTC
# Line 3  unit Utils; Line 3  unit Utils;
3  interface  interface
4  uses  uses
5    Controls,    Controls,
6    Graphics //TColor    Graphics, //TColor
7      IniFiles,
8      Windows //TFileTime
9    ;    ;
10    
11  type  type
# Line 24  type Line 26  type
26    
27      class function Sto_GetFmtFileVersion(const FileName: String = ''): String;      class function Sto_GetFmtFileVersion(const FileName: String = ''): String;
28    
29        class function CheckUrl(url:string): boolean;
30    
31        class function FileTime2DateTime(FileTime: TFileTime): TDateTime;
32    
33    
34    
35    
# Line 33  implementation Line 39  implementation
39    
40  uses StrUtils,  uses StrUtils,
41    Types, //TRect ,    Types, //TRect ,
   Windows,  
42    Messages,    Messages,
43    SysUtils, //IntToStr etc    SysUtils, //IntToStr etc
44    Registry    Registry,
45      wininet   //CheckUrl
46    
47    ;    ;
48    
# Line 236  begin Line 242  begin
242  end;  end;
243    
244    
245    class function TUtils.CheckUrl(url:string):boolean;
246    var
247      hSession, hfile: hInternet;
248      dwindex,dwcodelen :dword;
249      dwcode:array[1..20] of char;
250      res : pchar;
251    begin
252      if pos('http://',lowercase(url))=0 then
253        url := 'http://'+url;
254      Result := false;
255      hSession := InternetOpen('InetURL:/1.0',
256                                INTERNET_OPEN_TYPE_PRECONFIG,
257                                nil,
258                                nil,
259                                0);
260      if assigned(hsession) then
261      begin
262        hfile := InternetOpenUrl(hsession,
263                                 pchar(url),
264                                 nil,
265                                 0,
266                                 INTERNET_FLAG_RELOAD,
267                                 0);
268        dwIndex := 0;
269        dwCodeLen := 10;
270        HttpQueryInfo(hfile,
271                      HTTP_QUERY_STATUS_CODE,
272                      @dwcode,
273                      dwcodeLen,
274                      dwIndex);
275        res := pchar(@dwcode);
276        result:= (res ='200') or (res ='302');
277        if assigned(hfile) then
278          InternetCloseHandle(hfile);
279        InternetCloseHandle(hsession);
280      end;
281    
282    end;
283    
284    
285    class function TUtils.FileTime2DateTime(FileTime: TFileTime): TDateTime;
286    var
287       LocalFileTime: TFileTime;
288       SystemTime: TSystemTime;
289    begin
290       FileTimeToLocalFileTime(FileTime, LocalFileTime) ;
291       FileTimeToSystemTime(LocalFileTime, SystemTime) ;
292       Result := SystemTimeToDateTime(SystemTime) ;
293    end;
294    
295    
296  end.  end.

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

  ViewVC Help
Powered by ViewVC 1.1.20