Platform SDK: Performance Monitoring |
The EnumProcesses function retrieves the process identifier for each process object in the system.
BOOL EnumProcesses( DWORD *lpidProcess, // array of process identifiers DWORD cb, // size of array DWORD *cbNeeded // number of bytes returned );
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
It is a good idea to give EnumProcesses a large array of DWORD values, because it is hard to predict how many processes there will be at the time you call EnumProcesses. To determine how many processes were enumerated by the call to EnumProcesses, divide the resulting value in the cbNeeded parameter by sizeof(DWORD). There is no indication given when the buffer is too small to store all process identifiers.
To obtain process handles for the processes whose identifiers you have just obtained, call the OpenProcess function.
Windows NT/2000: Requires Windows NT 4.0 or later.
Header: Declared in Psapi.h.
Library: Use Psapi.lib.
Process Status Helper Overview, PSAPI Functions, OpenProcess