--- dao/DelphiScanner/Utils.pas 2015/09/03 14:31:39 2694 +++ dao/DelphiScanner/Utils.pas 2016/04/08 14:01:34 2996 @@ -3,7 +3,9 @@ interface uses Controls, - Graphics //TColor + Graphics, //TColor + IniFiles, + Windows //TFileTime ; type @@ -26,7 +28,13 @@ class function CheckUrl(url:string): boolean; + class function FileTime2DateTime(FileTime: TFileTime): TDateTime; + class function GetComputerNameHelper() : String; + + class function GetCurrentUserName : string; + + class function URLEncode(const s : string) : string; end; @@ -35,11 +43,13 @@ uses StrUtils, Types, //TRect , - Windows, Messages, SysUtils, //IntToStr etc Registry, - wininet //CheckUrl + wininet, //CheckUrl + + HTTPApp //HTTPEncode + ; @@ -278,4 +288,49 @@ end; + +class function TUtils.FileTime2DateTime(FileTime: TFileTime): TDateTime; +var + LocalFileTime: TFileTime; + SystemTime: TSystemTime; +begin + FileTimeToLocalFileTime(FileTime, LocalFileTime) ; + FileTimeToSystemTime(LocalFileTime, SystemTime) ; + Result := SystemTimeToDateTime(SystemTime) ; +end; + + +class function TUtils.GetComputerNameHelper : String; +var + buffer: array[0..255] of char; + size: dword; +begin + size := 256; + if GetComputerName(buffer, size) then + Result := buffer + else + Result := '' +end; + +class function TUtils.GetCurrentUserName : string; +const + cnMaxUserNameLen = 254; +var + sUserName : string; + dwUserNameLen : DWord; +begin + dwUserNameLen := cnMaxUserNameLen-1; + SetLength( sUserName, cnMaxUserNameLen ); + GetUserName(PChar( sUserName ),dwUserNameLen ); + SetLength( sUserName, dwUserNameLen ); + Result := sUserName; +end; + + +class function TUtils.URLEncode(const s : string) : string; +begin + result := HTTPEncode(s); +end; + + end.