Как перхватить сообщение открытия и закрытия любого файла(программы).Только давайте по конкретнее а не ответ типа "поставить хук". Если кто знает подскажите хотя бы какое сообщение посылает системе?
Вот как бы кусок программы который должен просчитывать начало работы программы через идентификатор процесса. Почему не работает?
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 GetProcessTimes Lib "kernel32" (ByVal hProcess 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 GetCurrentProcess Lib "kernel32" () As Long
Private Sub Form_Load()
Dim FT0 As FILETIME, FT1 As FILETIME, ST As SYSTEMTIME
GetProcessTimes GetCurrentProcess, FT1, FT0, FT0, FT0
FileTimeToLocalFileTime FT1, FT1
FileTimeToSystemTime FT1, ST
MsgBox "This program was started at " + CStr(ST.wHour) + ":" + CStr(ST.wMinute) + "." + CStr(ST.wSecond) + " on " + CStr(ST.wMonth) + "/" + CStr(ST.wDay) + "/" + CStr(ST.wYear)
End Sub