EnumProcesses

The EnumProcesses function retrieves the process identifier for each process object in the system.

BOOL EnumProcesses(
  DWORD * lpidProcess,  // array to receive the process identifiers
  DWORD cb,             // size of the array
  DWORD * cbNeeded      // receives the number of bytes returned
);
 

Parameters

lpidProcess
Pointer to an array that receives the list of process identifiers.
cb
Specifies the size, in bytes, of the lpidProcess array.
cbNeeded
Receives the number of bytes returned in the lpidProcess array.

Return Value

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.

Remarks

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).

To obtain process handles for the processes whose identifiers you have just obtained, call the OpenProcess function.

See Also

Process Status Helper Overview, PSAPI Functions, OpenProcess