- Private Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
- Private Declare Function NtSuspendProcess Lib "Ntdll.dll" (ByVal hProc As Long) As Long
- Private Declare Function NtResumeProcess Lib "Ntdll.dll" (ByVal hProc As Long) As Long
- Private Declare Function CloseHandle Lib "Kernel32.dll" (ByVal hObject As Long) As Long
- Private Const PROCESS_SUSPEND_RESUME As Long = &H800
- Public Function SuspendResumeProcess(ByVal Pid As Long, ByVal Action As Boolean) As Long
-
- Dim hProcess As Long
-
- hProcess = OpenProcess(PROCESS_SUSPEND_RESUME, 0&, Pid)
-
- If hProcess Then
- If Action Then
- SuspendResumeProcess = NtSuspendProcess(hProcess)
- Else
- SuspendResumeProcess = NtResumeProcess(hProcess)
- End If
- CloseHandle hProcess
- End If
- End Function