简体   繁体   中英

How can I get the state of a program?

I'm observing an program and want to kill it, if it is for some time in the state "wait:executive".

Here is a screenshot of the Process Explorer:

州:等:执行官

How can I get that state by code? Or could maybe tell me somebody what that state exactly mean? This will may help me to find the right query to solve my problem.

It means the thread is waiting for the scheduler/a component of the executive

It can be fetched with WMI Win32_Thread (or .net System.Diagnostics.ProcessThread WaitReason )

It is not state of program but it's state of thread.One process can have many threads.

You can call WaitForSingleObject to determine some states.

Also you can instantiate WMI using COM and selecting Win32_Thread class .

Here is some example.

More info here : How to determine that a win32 thread is either in Wait or Join or Sleep state in c++

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM