Собственно как мне измерить загрузку процессора(в процентах), для указаного процесса.
Как понимаю нужно взять GetProcessTimes, через некоторый промежуток времени еще раз GetProcessTimes и потом искать какое-то соотношение. Да? Если да, то какое?
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
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 GetCurrentProcess Lib "kernel32" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Dim FT1(3) As FILETIME
Dim FT2(3) As FILETIME
Dim HT As Long, LT As Long, cHWND As Long
cHWND = GetCurrentProcess
GetProcessTimes cHWND, FT1(0), FT1(1), FT1(2), FT1(3)
Sleep 1000
GetProcessTimes cHWND, FT2(0), FT2(1), FT2(2), FT2(3)
For I = 0 To 3
TMP = TMP & FT1(I).dwLowDateTime & ":" & FT1(I).dwHighDateTime & vbCrLf
tmp2 = tmp2 & FT2(I).dwLowDateTime & ":" & FT2(I).dwHighDateTime & vbCrLf
Next I
MsgBox TMP & vbCrLf & tmp2
End Sub
GetProcessTimes cHWND, FT1(0), FT1(1), FT1(2), FT1(3)
Sleep 1000
GetProcessTimes cHWND, FT2(0), FT2(1), FT2(2), FT2(3)
Сейчас этот форум просматривают: Yandex-бот и гости: 82