Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Process status with given pid

Posted on 2002-03-31
3
Medium Priority
?
292 Views
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.

Thanks.
0
Comment
Question by:bitnal
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 60 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.
0
 
LVL 4

Expert Comment

by:AssafLavie
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.
0
 
LVL 3

Expert Comment

by:stefanr
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...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

916 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