找到一个函数 Function Win32ToVbTime(ft As Currency) As Date Dim ftl As Currency ' Call API to convert from UTC time to local time If FileTimeToLocalFileTime(ft, ftl) Then ' Local time is nanoseconds since 01-01-1601 ' In Currency that comes out as milliseconds ' Divide by milliseconds per day to get days since 1601 ' Subtract days from 1601 to 1899 to get VB Date equivalent Win32ToVbTime = CDate((ftl / rMillisecondPerDay) - rDayZeroBias) Else MsgBox Err.LastDllError End If End Function
2380年 06月 7日 09:11:00 周六
转换了下,和LZ说的差别很大。
就不献丑了。
使用 ,获取ftp上文件的修改时间
FtpFindFirstFile 函数说明:http://msdn.microsoft.com/en-us/library/aa384146(v=VS.85).aspxFtpFindFirstFile 需要传入一个 WIN32_FIND_DATA, WIN32_FIND_DATA 这里包含文件修改时间
http://msdn.microsoft.com/en-us/library/aa365740
现在调用 FtpFindFirstFile 后,从WIN32_FIND_DATA.ftLastWriteTime可以返回修改时间。因为微软的列子是个WIN32_FIND_DATA.ftLastWriteTime 是个 FILETIME 类型,我找了一下资料在vb中可以用 Currency 代替,所以就取出了 12951969060000 这么一个值
Function Win32ToVbTime(ft As Currency) As Date
Dim ftl As Currency
' Call API to convert from UTC time to local time
If FileTimeToLocalFileTime(ft, ftl) Then
' Local time is nanoseconds since 01-01-1601
' In Currency that comes out as milliseconds
' Divide by milliseconds per day to get days since 1601
' Subtract days from 1601 to 1899 to get VB Date equivalent
Win32ToVbTime = CDate((ftl / rMillisecondPerDay) - rDayZeroBias)
Else
MsgBox Err.LastDllError
End If
End Function
Const rDayZeroBias As Double = 109205# ' Abs(CDbl(#01-01-1601#))
Const rMillisecondPerDay As Double = 10000000# * 60# * 60# * 24# / 10000#
忘了俩句