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
  • 36,141
  • 15
  • 83
  • 142
Ömer Faruk AK
  • 2,409
  • 5
  • 26
  • 47

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
  • 35,395
  • 6
  • 71
  • 104
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
  • 61,140
  • 12
  • 83
  • 180