例子
Private Declare Function FileTimeToDosDateTime Lib "kernel32" (lpFileTime As FILETIME, ByVal lpFatDate As Long, ByVal lpFatTime As Long) As LongPrivate Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As LongPrivate Declare Function lopen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As LongPrivate Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As LongPrivate Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As LongPrivate Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End TypePrivate 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 TypePrivate Const READ_WRITE = 2Dim hf As Long
Dim CreationTime As FILETIME
Dim LastAccessTime As FILETIME
Dim LastWriteTime As FILETIME
Dim LocalFileTime As FILETIME
Dim FatDate As Long
Dim FatTime As Long
Dim str1 As String
Dim str2 As String
Dim temp As Long
Dim STime As SYSTEMTIMEPrivate Sub Form_Load()
str1 = "c:\temp\NWind.mdb"
hf = lopen(str1, READ_WRITE)
temp = GetFileTime(hf, CreationTime, LastAccessTime, LastWriteTime)
FileTimeToLocalFileTime CreationTime, LocalFileTime
'FileTimeToDosDateTime CreationTime, FatDate, FatTime
FileTimeToSystemTime LocalFileTime, STime
str2 = ""
str2 = str2 + "文件创建时间:"
str2 = str2 + CStr(STime.wYear) + "年"
str2 = str2 + CStr(STime.wMonth) + "月"
str2 = str2 + CStr(STime.wDay) + "日"
str2 = str2 + CStr(STime.wHour) + "时"
str2 = str2 + CStr(STime.wMinute) + "分"
str2 = str2 + CStr(STime.wSecond) + "秒"
MsgBox str2
FileTimeToLocalFileTime LastAccessTime, LocalFileTime
str2 = ""
str2 = str2 + "文件上一次访问的时间:"
FileTimeToSystemTime LocalFileTime, STime
str2 = str2 + CStr(STime.wYear) + "年"
str2 = str2 + CStr(STime.wMonth) + "月"
str2 = str2 + CStr(STime.wDay) + "日"
str2 = str2 + CStr(STime.wHour) + "时"
str2 = str2 + CStr(STime.wMinute) + "分"
str2 = str2 + CStr(STime.wSecond) + "秒"
MsgBox str2
FileTimeToLocalFileTime LastWriteTime, LocalFileTime
str2 = ""
str2 = "文件上一次修改的时间:" + str2
FileTimeToSystemTime LocalFileTime, STime
str2 = str2 + CStr(STime.wYear) + "年"
str2 = str2 + CStr(STime.wMonth) + "月"
str2 = str2 + CStr(STime.wDay) + "日"
str2 = str2 + CStr(STime.wHour) + "时"
str2 = str2 + CStr(STime.wMinute) + "分"
str2 = str2 + CStr(STime.wSecond) + "秒"
MsgBox str2
End Sub
Private Declare Function FileTimeToDosDateTime Lib "kernel32" (lpFileTime As FILETIME, ByVal lpFatDate As Long, ByVal lpFatTime As Long) As LongPrivate Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As LongPrivate Declare Function lopen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As LongPrivate Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As LongPrivate Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As LongPrivate Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End TypePrivate 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 TypePrivate Const READ_WRITE = 2Dim hf As Long
Dim CreationTime As FILETIME
Dim LastAccessTime As FILETIME
Dim LastWriteTime As FILETIME
Dim LocalFileTime As FILETIME
Dim FatDate As Long
Dim FatTime As Long
Dim str1 As String
Dim str2 As String
Dim temp As Long
Dim STime As SYSTEMTIMEPrivate Sub Form_Load()
str1 = "c:\temp\NWind.mdb"
hf = lopen(str1, READ_WRITE)
temp = GetFileTime(hf, CreationTime, LastAccessTime, LastWriteTime)
FileTimeToLocalFileTime CreationTime, LocalFileTime
'FileTimeToDosDateTime CreationTime, FatDate, FatTime
FileTimeToSystemTime LocalFileTime, STime
str2 = ""
str2 = str2 + "文件创建时间:"
str2 = str2 + CStr(STime.wYear) + "年"
str2 = str2 + CStr(STime.wMonth) + "月"
str2 = str2 + CStr(STime.wDay) + "日"
str2 = str2 + CStr(STime.wHour) + "时"
str2 = str2 + CStr(STime.wMinute) + "分"
str2 = str2 + CStr(STime.wSecond) + "秒"
MsgBox str2
FileTimeToLocalFileTime LastAccessTime, LocalFileTime
str2 = ""
str2 = str2 + "文件上一次访问的时间:"
FileTimeToSystemTime LocalFileTime, STime
str2 = str2 + CStr(STime.wYear) + "年"
str2 = str2 + CStr(STime.wMonth) + "月"
str2 = str2 + CStr(STime.wDay) + "日"
str2 = str2 + CStr(STime.wHour) + "时"
str2 = str2 + CStr(STime.wMinute) + "分"
str2 = str2 + CStr(STime.wSecond) + "秒"
MsgBox str2
FileTimeToLocalFileTime LastWriteTime, LocalFileTime
str2 = ""
str2 = "文件上一次修改的时间:" + str2
FileTimeToSystemTime LocalFileTime, STime
str2 = str2 + CStr(STime.wYear) + "年"
str2 = str2 + CStr(STime.wMonth) + "月"
str2 = str2 + CStr(STime.wDay) + "日"
str2 = str2 + CStr(STime.wHour) + "时"
str2 = str2 + CStr(STime.wMinute) + "分"
str2 = str2 + CStr(STime.wSecond) + "秒"
MsgBox str2
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货