GetConsoleProcessList function

Retrieves a list of the processes attached to the current console.


DWORD WINAPI GetConsoleProcessList(
  _Out_ LPDWORD lpdwProcessList,
  _In_  DWORD   dwProcessCount


lpdwProcessList [out]
A pointer to a buffer that receives an array of process identifiers upon success.

dwProcessCount [in]
The maximum number of process identifiers that can be stored in the lpdwProcessList buffer.

Return value

If the function succeeds, the return value is less than or equal to dwProcessCount and represents the number of process identifiers stored in the lpdwProcessList buffer.

If the buffer is too small to hold all the valid process identifiers, the return value is the required number of array elements. The function will have stored no identifiers in the buffer. In this situation, use the return value to allocate a buffer that is large enough to store the entire list and call the function again.

If the return value is zero, the function has failed, because every console has at least one process associated with it. To get extended error information, call GetLastError.


To compile an application that uses this function, define _WIN32_WINNT as 0x0501 or later. For more information, see Using the Windows Headers.


Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]


ConsoleApi3.h (via Wincon.h, include Windows.h)





See also


Console Functions