• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

Process status with given pid

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.

Thanks.
0
bitnal
Asked:
bitnal
1 Solution
 
mnashadkaCommented:
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.
0
 
AssafLavieCommented:
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.
0
 
stefanrCommented:
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...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now