class CProcessList

Win32 process list

Inheritance:


Public Methods

static CProcessList* Create ()
Create a process list object
virtual CProcess* GetNextProcess ()
Get the next process from the list
virtual bool SnapShot ()
Create a snapshot of all currently running processes
virtual ~CProcessList ()
Destructor

Documentation

Win32 process list. Note that you cannot instantiate an object of this class. Instead you have to use the static member function Create() to obtain a valid object. You have to delete this object, if you no longer need this object. The goal of the Create method is to find the best process enumerator on the current system. On a Win95/98 it uses the toolhelp32 library and on NT it uses the PSAPI or the performance database, if no PSAPI is present. The return of Create() is a pointer to an object of a more specialised class.

Usage:

// find out the best process enumerator method
CProcessList * pProcessList = CProcessList::Create();
ASSERT(pProcList != 0);

// make a snapshot of all running processes
pProcessList->SnapShot();

// loop through the processes
CProcess * pProcess;
while((pProcess = pProcessList->GetNextProcess()) != 0) {
	// do whatever you want to do with that process
}

// eventually you want to reuse the object
pProcessList->SnapShot();
// ...

// if it is no longer needed -> delete it
delete pProcessList;
static CProcessList* Create()
Create a process list object. Find out what's the best process enumerator method and create an object that is able to perform this method. Note that calling this method actually does not perform the enumerator method. Use the SnapShot() method to invoke the process enumerator.

virtual bool SnapShot()
Create a snapshot of all currently running processes. The method uses the best process enumerator available on the current machine (see derived classes). This method can be called multiple times. Note that, if your iterating the process list and call SnapShot() again, your iteration becomes invalid (in fact the next call to GetNextProcess() restarts the iteration).

virtual CProcess* GetNextProcess()
Get the next process from the list. This method should only be called after the SnapShot() was taken. If called the first time, it returns the first process in the list. At the end of the list this method returns NULL.

virtual ~CProcessList()
Destructor. Note that you have to delete the object returned by Create(), if it is not longer needed.


Direct child classes:
CProcessListNTPS
CProcessListNT
CProcessList98

alphabetic index hierarchy of classes


generated by doc++