function TForm1.ChkThreadAlive: boolean;
var
dwExitCode: DWORD;
fprocessExit: boolean;
ComThd:TThread;
begin
Result := False;
dwExitCode := 0;
//******** ComThd 为一线程 *********
if not Assigned(ComThd) then
Exit;
fprocessExit := GetExitCodeThread(ComThd.Handle, dwExitCode);
if (fprocessExit and (dwExitCode <> STILL_ACTIVE)) then
begin
Memo1.Lines.Add('ComThd 线程终止');
CloseHandle(ComThd.Handle);
Exit;
end;
Result := True;
end;
函数GetExitCodeThread和常量still_active 都是在 windows 里定义的啊。不需要手工uses