procedure THook.setThreads(state: Boolean);
var
pid, tid: DWORD;
hsnap, hthread: DWORD;
te: TThreadEntry32;
begin
pid := GetCurrentProcessId;
tid := GetCurrentThreadId;
hsnap := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if hsnap = 0 then
Exit;
te.dwSize := SizeOf(te);
if Thread32First(hsnap, te) then begin
repeat
if (te.th32OwnerProcessID = pid) and (te.th32ThreadID <> tid) then begin
hthread := OpenThread(THREAD_SUSPEND_RESUME, False, te.th32ThreadID);
if not state then
SuspendThread(hthread)
else
ResumeThread(hthread);
CloseHandle(hthread);
end;
until not Thread32Next(hsnap, te);
end;
CloseHandle(hsnap);
end;