Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just found the following snippets <a href="http://www.delphibasics.info/home/delphibasicssnippets/howtosuspendprocessresumeprocess" rel="nofollow">here</a> (Author: steve10120).</p> <p>I think they are valuables and I can't help posting them also as an alternative answer to my own question.</p> <hr> <p><strong>Resume Process:</strong></p> <pre><code>function ResumeProcess(ProcessID: DWORD): Boolean; var Snapshot,cThr: DWORD; ThrHandle: THandle; Thread:TThreadEntry32; begin Result := False; cThr := GetCurrentThreadId; Snapshot := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); if Snapshot &lt;&gt; INVALID_HANDLE_VALUE then begin Thread.dwSize := SizeOf(TThreadEntry32); if Thread32First(Snapshot, Thread) then repeat if (Thread.th32ThreadID &lt;&gt; cThr) and (Thread.th32OwnerProcessID = ProcessID) then begin ThrHandle := OpenThread(THREAD_ALL_ACCESS, false, Thread.th32ThreadID); if ThrHandle = 0 then Exit; ResumeThread(ThrHandle); CloseHandle(ThrHandle); end; until not Thread32Next(Snapshot, Thread); Result := CloseHandle(Snapshot); end; end; </code></pre> <hr> <p><strong>Suspend Process:</strong></p> <pre><code>function SuspendProcess(PID:DWORD):Boolean; var hSnap: THandle; THR32: THREADENTRY32; hOpen: THandle; begin Result := FALSE; hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); if hSnap &lt;&gt; INVALID_HANDLE_VALUE then begin THR32.dwSize := SizeOf(THR32); Thread32First(hSnap, THR32); repeat if THR32.th32OwnerProcessID = PID then begin hOpen := OpenThread($0002, FALSE, THR32.th32ThreadID); if hOpen &lt;&gt; INVALID_HANDLE_VALUE then begin Result := TRUE; SuspendThread(hOpen); CloseHandle(hOpen); end; end; until Thread32Next(hSnap, THR32) = FALSE; CloseHandle(hSnap); end; end; </code></pre> <hr> <p><strong>Disclaimer:</strong></p> <p>I didn't test them at all. Please enjoy and don't forget to feedback.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload