Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Access 97: GetFileTime API call

6 views
Skip to first unread message

John Powell

unread,
Jun 19, 1998, 3:00:00 AM6/19/98
to

I need to find or create a function that takes a fileName (and path) and
returns the datetime stamp of the file.

I found some references to an API call called "GetFileTime", but am still a
bit green at Access 97. What tools/references do I need to have checked to
use it?

Any other references I might find helpful?

Thanks, as always, for any insight.

John Powell
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If there is anything the nonconformist hates worse
than a conformist it's a nonconformist who doesn't
conform to the prevailing standard of nonconformity.

This page contains links to all MS Access FAQ's and
resources (except the ones I don't have listed). If you
feel left out, let me know and I'll add you in.
http://www.wavefront.com/~pow/john.htm#msaccess
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Cliff Knight

unread,
Jun 19, 1998, 3:00:00 AM6/19/98
to

Access 7 has this built-in:

FileDateTime(pathname)

Hope this helps...

--
-cliff knight-
cli...@ix.netcom.com
cliffor...@doh.state.fl.us

John Powell wrote in message <4gwi1.115$P8.4...@ptah.visi.com>...

John Powell

unread,
Jun 19, 1998, 3:00:00 AM6/19/98
to

I had just found this and was rushing back to "take back" my question before
someone answered it.

That's what I get for starting at MSDN and DejaNews instead of in the
regular old help files...

Thanks, though, I'm catchin' on

John Powell
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If there is anything the nonconformist hates worse
than a conformist it's a nonconformist who doesn't
conform to the prevailing standard of nonconformity.

This page contains links to all MS Access FAQ's and
resources (except the ones I don't have listed). If you
feel left out, let me know and I'll add you in.
http://www.wavefront.com/~pow/john.htm#msaccess
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Cliff Knight wrote in message
<46yi1.2949$SC1.2...@news2.atl.bellsouth.net>...

Dev Ashish

unread,
Jun 19, 1998, 3:00:00 AM6/19/98
to

If you mean the last modified time, it's built in ...
FileDateTime(stFileName)

If you mean the Creation date, try this

'************ Code Start ***********
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Private Type BY_HANDLE_FILE_INFORMATION
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
dwVolumeSerialNumber As Long
nFileSizeHigh As Long
nFileSizeLow As Long
nNumberOfLinks As Long
nFileIndexHigh As Long
nFileIndexLow As Long
End Type

Private Type SYSTEMTIME ' 16 Bytes
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

Private Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Const FILE_ATTRIBUTE_COMPRESSED = &H800
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
Private Const FILE_ATTRIBUTE_HIDDEN = &H2
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const FILE_ATTRIBUTE_READONLY = &H1
Private Const FILE_ATTRIBUTE_SYSTEM = &H4
Private Const FILE_ATTRIBUTE_TEMPORARY = &H100
Private Const GENERIC_READ = &H80000000
Private Const OPEN_EXISTING = 3
Private Const INVALID_HANDLE_VALUE = -1
Private Const ERR_API = 0
Private Const ERR_DOH = vbObjectError + 9999

Private Declare Function apiGetFileInformationByHandle Lib "kernel32" _
Alias "GetFileInformationByHandle" _
(ByVal hFile As Long, _
lpFileInformation As BY_HANDLE_FILE_INFORMATION) _
As Long

Private Declare Function apiCreateFile 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 apiCloseHandle Lib "kernel32" _
Alias "CloseHandle" _
(ByVal hObject As Long) _
As Long

Private Declare Function apiFileTimeToSystemTime Lib "kernel32" _
Alias "FileTimeToSystemTime" _
(lpFileTime As FILETIME, _
lpSystemTime As SYSTEMTIME) _
As Long

Function fTimeCreated(stFile As String)
Dim lngH As Long, lngRet As Long, lngX As Long
Dim tTime As FILETIME, tFileInfo As BY_HANDLE_FILE_INFORMATION
Dim tSysTime As SYSTEMTIME, dtTmp As Date

On Error GoTo err_fTimeCreated
lngH = apiCreateFile(stFile, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)

If lngH = INVALID_HANDLE_VALUE Then Err.Raise ERR_DOH

lngRet = apiGetFileInformationByHandle(lngH, tFileInfo)

If lngRet = ERR_API Then Err.Raise ERR_DOH

lngX = apiFileTimeToSystemTime(tFileInfo.ftCreationTime, tSysTime)

If lngRet = ERR_API Then Err.Raise ERR_DOH

With tSysTime
dtTmp = CDate(DateSerial(.wYear, .wMonth, .wDay) & " " & _
Format(.wHour, "00") & ":" & _
Format(.wMinute, "00") & ":" & _
Format(.wSecond, "00"))
End With
fTimeCreated = dtTmp
exit_fTimeCreated:
On Error Resume Next
lngX = apiCloseHandle(lngH)
Exit Function

err_fTimeCreated:
fTimeCreated = Null
Resume exit_fTimeCreated
End Function
'************ Code End ***********

--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

:

0 new messages