如何从WinApi转换FILETIME(例如从调用this WINAPI function的结果转换为vb6中的DateTime?(例如,如果我想将它用作DateTime.DateDiff函数的输入。)
答案 0 :(得分:4)
Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Public 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
Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Private Declare Function SystemTimeToVariantTime Lib "OLEAUT32.DLL" (lpSystemTime As SYSTEMTIME, vtime As Date) As Long
Dim st As SYSTEMTIME
Dim dt As Date
' convert a FILETIME to SYSTEMTIME first
FileTimeToSystemTime ft, st
' convert the SYSTEMTIME to a Variant date (VT_DATE)
SystemTimeToVariantTime st, dt