1

At my operating system course in a project we have to get process status. We are coding with c.

Example output:

Process No Process Id Program Name Status Handle Count

1          5780       notepad.exe  ACTIVE 1

How can i get status and handle count?

tenfour
  • 35,101
  • 13
  • 77
  • 137
Ömer Faruk AK
  • 2,329
  • 4
  • 24
  • 46

2 Answers2

2

Get a process handle using OpenProcess with PROCESS_QUERY_INFORMATION as the desired access (or use a handle previously obtained, possibly from CreateProcess), then try to get its termination status using GetExitCodeProcess. If it returns STILL_ACTIVE, the process has not terminated yet, otherwise it has. Don't forget to close the handle using CloseHandle

Hasturkun
  • 33,910
  • 5
  • 73
  • 99
0

The first 2 or 3 columns are more or less trivial. Look up msdn for process enumeration.
Handle enumeration is a bit trickier, but also doable, see these: link1 link2

Community
  • 1
  • 1
Alexey Frunze
  • 59,618
  • 10
  • 77
  • 173