本文整理自网络,侵删。
delphi判断线程是否释放
function CheckThreadFreed(aThread: TThread): Byte;
var
i: DWord;
IsQuit: Boolean;
begin
if Assigned(aThread) then
begin
IsQuit := GetExitCodeThread(aThread.Handle, i);
if IsQuit then // If the function succeeds, the return value is nonzero.
begin
if i = STILL_ACTIVE then // If the specified thread has not terminated,
Result := 1
else
Result := 2; //aThread未Free,因为Tthread.Destroy中有执行语句
end else
Result := 0; //可以用GetLastError取得错误代码
end else
Result := 3;
end;
相关阅读 >>
在Delphi如何实现模拟组合按键,如发送ctrl_f的按键消息
Delphi twebbrowser与嵌入youtube视频崩溃
更多相关阅读请进入《Delphi》频道 >>