/[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 2694 by torben, Thu Sep 3 14:31:39 2015 UTC revision 2996 by torben, Fri Apr 8 14:01:34 2016 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 26  type Line 28  type
28    
29      class function CheckUrl(url:string): boolean;      class function CheckUrl(url:string): boolean;
30    
31        class function FileTime2DateTime(FileTime: TFileTime): TDateTime;
32    
33        class function GetComputerNameHelper() : String;
34    
35        class function GetCurrentUserName : string;
36    
37        class function URLEncode(const s : string) : string;
38    
39    
40    end;    end;
# Line 35  implementation Line 43  implementation
43    
44  uses StrUtils,  uses StrUtils,
45    Types, //TRect ,    Types, //TRect ,
   Windows,  
46    Messages,    Messages,
47    SysUtils, //IntToStr etc    SysUtils, //IntToStr etc
48    Registry,    Registry,
49    wininet   //CheckUrl    wininet,   //CheckUrl
50    
51      HTTPApp //HTTPEncode
52    
53    
54    ;    ;
55    
# Line 278  begin Line 288  begin
288    
289  end;  end;
290    
291    
292    class function TUtils.FileTime2DateTime(FileTime: TFileTime): TDateTime;
293    var
294       LocalFileTime: TFileTime;
295       SystemTime: TSystemTime;
296    begin
297       FileTimeToLocalFileTime(FileTime, LocalFileTime) ;
298       FileTimeToSystemTime(LocalFileTime, SystemTime) ;
299       Result := SystemTimeToDateTime(SystemTime) ;
300    end;
301    
302    
303    class function TUtils.GetComputerNameHelper : String;
304    var
305      buffer: array[0..255] of char;
306      size: dword;
307    begin
308      size := 256;
309      if GetComputerName(buffer, size) then
310        Result := buffer
311      else
312        Result := ''
313    end;
314    
315    class function TUtils.GetCurrentUserName : string;
316    const
317      cnMaxUserNameLen = 254;
318    var
319      sUserName     : string;
320      dwUserNameLen : DWord;
321    begin
322      dwUserNameLen := cnMaxUserNameLen-1;
323      SetLength( sUserName, cnMaxUserNameLen );
324      GetUserName(PChar( sUserName ),dwUserNameLen );
325      SetLength( sUserName, dwUserNameLen );
326      Result := sUserName;
327    end;
328    
329    
330    class function TUtils.URLEncode(const s : string) : string;
331    begin
332      result := HTTPEncode(s);
333    end;
334    
335    
336  end.  end.

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

  ViewVC Help
Powered by ViewVC 1.1.20