本文整理自网络,侵删。
//以下资料来自大富翁论坛。
/判断线程是否释放
//返回值:0-已释放;1-正在运行;2-已终止但未释放;
//3-未建立或不存在
function TFrmMain.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.
//If the function fails, the return value is zero.
begin
if i = STILL_ACTIVE then //If the specified thread has not terminated,
//the termination status returned is STILL_ACTIVE.
Result := 1
else
Result := 2; //aThread未Free,因为Tthread.Destroy中有执行语句
end
else
Result := 0; //可以用GetLastError取得错误代码
end
else
Result := 3;
end;
相关阅读 >>
Delphi d10.x安卓app开发中简单使用原生toast
Delphi 中的md5实现方法及Delphi2009和Delphi2010中用法
Delphiwindows 下编译 exe 文件时把一个外部 txt 文件编译到 exe 里面
Delphi 掌控pagecontrol中的右上方的左右箭头事件
更多相关阅读请进入《Delphi》频道 >>