Wednesday, April 29, 2009

Thread Time

'Thread Time



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



Private Declare Function GetThreadTimes
Lib "kernel32" _

(ByVal hThread As Long, lpCreationTime As FILETIME, _

lpExitTime As FILETIME, lpKernelTime As FILETIME, _

lpUserTime 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
GetCurrentThread Lib "kernel32" () As Long


Private Sub Form_Load()

Dim FT0 As FILETIME, FT1
As FILETIME, ST As
SYSTEMTIME
GetThreadTimes GetCurrentThread, FT1, FT0, FT0, FT0
FileTimeToLocalFileTime FT1, FT1

FileTimeToSystemTime FT1, ST

MsgBox "This thread was started at " + CStr(ST.wHour) + ":" _

+ CStr(ST.wMinute) + "." +
CStr(ST.wSecond) + " on " + _

CStr(ST.wMonth) + "/" +
CStr(ST.wDay) + "/" +
CStr(ST.wYear)

End Sub



 

No comments:

Post a Comment