Solved

Process status with given pid

Posted on 2002-03-31
3
290 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 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.
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object modeling - load and save functions 5 61
Cross compile release version of c++ program for linux 2 132
Create a path if not exists 7 77
Issues with C++ Class 19 92
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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

776 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