public static void ResumeProcess(this Process process) { if (process.ProcessName == string.Empty) { return; } foreach (ProcessThread pT in process.Threads) { IntPtr pOpenThread = WinAPI.OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id); if (pOpenThread == IntPtr.Zero) { continue; } var suspendCount = 0; do { suspendCount = WinAPI.ResumeThread(pOpenThread); } while (suspendCount > 0); WinAPI.CloseHandle(pOpenThread); } }
public static void SuspendProcess(this Process process) { if (process.ProcessName == string.Empty) { return; } foreach (ProcessThread pT in process.Threads) { IntPtr pOpenThread = WinAPI.OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id); if (pOpenThread == IntPtr.Zero) { continue; } WinAPI.SuspendThread(pOpenThread); WinAPI.CloseHandle(pOpenThread); } }