FAppHandle := OpenProcess(PROCESS_QUERY_INFORMATION,False,lpProcessInformation.dwProcessId);
//GetExitCodeProcess
If Not Verifyhaskett then
GetExitCodeProcess(FAppHandle,FAppState);
假设test为一个线程类
var
test:TTestThread;
用下面语句来判断一个线程是否存在
var
i:dword;
isquit:boolean;
if assigned(test)
begin
isquit:=GetExitCodeThread(test.handle,i);
if isquit then
/test未free,因为tthread.destroy中有执行语句
//if FHandle <> 0 then
CloseHandle(FHandle);
begin
if i=STILL_ACTIVE then
showmessage('线程在活动中')
else
showmessage('线程已终止terminate,但句柄未释放free');
end
else
begin
showmessage('线程句柄已释放free');
//可以用GetLastError取得错误代码
end;