在c ++ / windows中获得线程状态 [英] getting a thread state in c++/windows

查看:1111
本文介绍了在c ++ / windows中获得线程状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



必须有一个函数获取系统中线程的当前状态,因为

有此应用程序: http://www.softwareverify.com/cpp/thread-status-monitor/index.html



它必须使用某种API函数或某种...
如何在C ++ / Windows中获得线程状态?

谢谢:)



(这是我今天的最后一个问题,我保证:))

解决方案

您可以使用以下示例来获取正在运行的进程,以及当您拥有进程ID时的线程。



拍摄快照并查看进程



遍历线程列表



编辑:获取线程的句柄后,你可以调用 GetExitCodeThread 但是它只会告诉你线程是否 STILL_ACTIVE ,直到它结束,当你可以找到退出代码。 >

在搜索您的评论的其他信息时,我也遇到了这个线程,你可能会感兴趣。



There must be a function that gets the current status of a thread in the system because
there is this application: http://www.softwareverify.com/cpp/thread-status-monitor/index.html

It must be using some sort of API function or something... How can I get a thread state myself in C++/Windows?
thanks :)

(this is my last question for today. I promise :))

解决方案

You can use the following examples to get the running processes and, when you have a process ID, the threads.

Taking a Snapshot and Viewing Processes

Traversing the Thread List

EDIT: After getting the handle to the thread(s) you are interested in you can call GetExitCodeThread but that will only tell you if the thread is STILL_ACTIVE until it ends, when you can find the exit code.

While searching for the additional information for your comment I also came across this thread on SO which might be of interest to you.

这篇关于在c ++ / windows中获得线程状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆