Attribute VB_Name = "GetTime" Option Explicit Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type Private Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type Public Enum DTvalue DT_CREATED = &H1 DT_ACCESSED = &H2 DT_LASTMODIFIED = &H3 End Enum Private Const GENERIC_WRITE = &H40000000 Private Const OPEN_EXISTING = 3 Private Const FILE_SHARE_READ = &H1 Private Const FILE_SHARE_WRITE = &H2 Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Public Function GetFTime(ByVal File As String, DTDate As DTvalue, Optional BetweenDT As String = "") As String Dim lngHandle As Long Dim FT1 As FILETIME, FT2 As FILETIME, FT3 As FILETIME, FT4 As FILETIME Dim SysTime As SYSTEMTIME lngHandle = CreateFile(File, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0) Call GetFileTime(lngHandle, FT1, FT2, FT3) Select Case DTDate Case DT_CREATED FileTimeToLocalFileTime FT1, FT4 Case DT_ACCESSED FileTimeToLocalFileTime FT2, FT4 Case DT_LASTMODIFIED FileTimeToLocalFileTime FT3, FT4 Case Else Exit Function End Select FileTimeToSystemTime FT4, SysTime CloseHandle lngHandle GetFTime = Format(Str$(SysTime.wDay), "00") _ & "/" & Format(Trim(Str$(SysTime.wMonth)), "00") _ & "/" + Trim(Str$(SysTime.wYear)) _ & BetweenDT _ & " " & Format(Str$(SysTime.wHour), "00") _ & ":" & Format(Str$(SysTime.wMinute), "00") _ & ":" & Format(Str$(SysTime.wSecond), "00") End Function