Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

GetProcessTimes CPU process usage percent

GetProcessTimes CPU process usage percent

it does not show correctly,
how to work with big numbers? 64bit

Private Sub timCPU_Timer()
On Error Resume Next

hProc = OpenProcess(PROCESS_QUERY_INFORMATION, 0, Val(txtPID))

Static ftKernelStart As FILETIME
Static ftUserStart As FILETIME
bRet = GetProcessTimes(hProc, ftCreat, ftExit, ftKernel, ftUser)
Dim PU As Double
PU = ((ftKernel.dwLowDateTime - ftKernelStart.dwLowDateTime) + (ftUser.dwLowDateTime - ftUserStart.dwLowDateTime) / 1000) * 100
PU = PU / 10000000

If PU > maxcpu And PU <= 100 Then
maxcpu = PU
txtMAX.Text = CStr(maxcpu)
End If

txtCPU.Text = CStr(PU)
ftKernelStart = ftKernel
ftUserStart = ftUser
End Sub
[874 byte] By [eugene2005] at [2007-11-11 9:56:14]
# 1 Re: GetProcessTimes CPU process usage percent
http://vb.mvps.org/hardcore/html/filedatestimes.htm
Phil Weber at 2007-11-11 17:23:33 >