delphi判断线程是否正在运行


本文整理自网络,侵删。

 //以下资料来自大富翁论坛。
/判断线程是否释放
//返回值: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 切换开关 toggleswitch1

Delphi windows 编程[12] - 菜单与菜单资源(1-3)

Delphi tfontdialog

Delphi之木马生成原理(资源文件,和文件流的应用)

Delphi access数据库密码的mdb的访问报错“无法启动应用程序,或是已被其他用户已独占方式打开”

Delphi 控制memo1滚动条

截取程序的网络封包(Delphi hook api)

print documents from Delphi - print pdf, doc, xls, html, rtf, docx, txt

Delphi中进行指纹仪的二次开发

Delphi 将strings合并成一个逗号分隔的字符串,用于sql

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...