Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


FileTime in GMT format

Keywords: 	 FileTime in GMT format.wbt

Here's a routine that will get the GMT file time, returned in YmdHms format.
;--------------------------------------------
;  Given a file name, gets the
;  file "Last Modify" time in GMT.
;
;  Returns the time as YYYY:MM:DD:HH:MM:SS
;
;  If the file is not found, returns ""
'--------------------------------------------

#DefineFunction GMTFileTime(TheFile)
  Kernel32 = DllLoad(strcat(dirwindows(1),"Kernel32.DLL"))
  Data = BinaryAlloc(320)

  Handle = DllCall(Kernel32,long:"FindFirstFileA",lpstr:TheFile,lpbinary:Data)
  if Handle == -1 ; File Not Found?
    BinaryFree(Data)
    DllFree(Kernel32)
    return ""
  endif
  DllCall(Kernel32,long:"FindClose",long:Handle)
  FT = BinaryAlloc(8)
  BinaryCopy(FT,0,Data,12,8)
  DllCall(Kernel32,long:"FileTimeToSystemTime",lpbinary:FT,lpbinary:Data)
  DllFree(Kernel32)
  BinaryFree(FT)

  Y = BinaryPeek2(Data,0)
  M = StrFixLeft(BinaryPeek2(Data,2),"0",2)
  D = StrFixLeft(BinaryPeek2(Data,6),"0",2)
  H = StrFixLeft(BinaryPeek2(Data,8),"0",2)
  N = StrFixLeft(BinaryPeek2(Data,10),"0",2)
  S = StrFixLeft(BinaryPeek2(Data,12),"0",2)
  BinaryFree(Data)
  return StrCat(Y,":",M,":",D,":",H,":",N,":",S)
#EndFunction



FileTIme = GMTFileTime("Some\File")