uses 절에 tlhelp32 추가
//////////////
interface 절에 아래 추가
function OpenThread(dwDesiredAccess: DWORD; bInheritHandle: BOOL;
dwThreadId: DWORD): THandle; stdcall; external kernel32;
/////////////
Procedure SuspendProcess( PID : DWORD );
const
THREAD_SUSPEND_RESUME = $0002;
var
nThread : THREADENTRY32;
i,j : integer;
hSnap,hThread : THandle;
Return : Boolean;
begin
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,0);
if hSnap = 0 then
Exit;
nThread.dwSize := SizeOf(nThread);
Return := Thread32First(hSnap,nThread);
while Return do
begin
if nThread.th32OwnerProcessID = PID then
begin
hThread := OpenThread(THREAD_SUSPEND_RESUME,False,nThread.th3 2ThreadID);
SuspendThread(hThread);
end;
Return := Thread32Next(hSnap,nThread);
end;
end;
Procedure ResumeProcess( PID : DWORD);
const
THREAD_SUSPEND_RESUME = $0002;
var
nThread : THREADENTRY32;
i,j : integer;
hSnap,hThread : THandle;
Return : Boolean;
begin
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,0);
if hSnap = 0 then
Exit;
nThread.dwSize := SizeOf(nThread);
Return := Thread32First(hSnap,nThread);
while Return do
begin
if nThread.th32OwnerProcessID = PID then
begin
hThread := OpenThread(THREAD_SUSPEND_RESUME,False,nThread.th3 2ThreadID);
ResumeThread(hThread);
end;
Return := Thread32Next(hSnap,nThread);
end;
end;