Process status with given pid

Posted on 2002-03-31
Last Modified: 2010-04-02
I have a list of PIDs in a flat file and have to find out if any of those are inactive .
Any pointers on how to do this?
Platform: Windows NT
This info has to be read and processed within a MFC GUI.

Question by:bitnal
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

mnashadka earned 20 total points
ID: 6909066
You can use the EnumProcesses function to retrieve an array of process id's, like:

  DWORD processes[200] = {0};
  DWORD num_bytes;
  EnumProcesses(processes, 200 * sizeof(DWORD), &num_bytes);
  int process_count = num_bytes / sizeof(DWORD);

Hope this helps.

Expert Comment

ID: 6910097
What do you mean by 'inactive'? Shut down?
Anyway, IIRC, you can use the pid's with OpenProcess and see if you get a valid handle.

Expert Comment

ID: 6912659
Another issue that perhaps needs to be considered when having a list of saved PID's like this is that Windows may very well reuse a PID of a process that just have been shut down for a new process...

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question