Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const PROCESS_ALL_ACCESS=& amp; H1F0FFF
Private Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
Private Const WAIT_TIMEOUT=258
The Function IsTargetNotResponding (ByVal lProcessID As Long, Optional ByVal lTimeoutValue As Long=1000) As a Boolean
Dim hProcess As Long
HProcess=OpenProcess (PROCESS_ALL_ACCESS, 0, lProcessID)
IsTargetNotResponding=(WaitForInputIdle (hProcess, lTimeoutValue)=WAIT_TIMEOUT)
The CloseHandle hProcess
End the Function
Private Sub Form_Load ()
Dim lTargetProcessID As Long
LTargetProcessID=& amp; H148
'wait for 1000 milliseconds
The Debug. Print IsTargetNotResponding (lTargetProcessID, 1000)
End Sub
lTargetProcessID=& amp; H148 me & amp; PID H148 changed to the corresponding program, such as explorer is 2028, and then after I was hung with tools is still false, with no other process, too, is this why?
CodePudding user response:
Please judge the return values of each API callView a detailed explanation of the API in the MSDN,