The system maintains a list of running processes. You can retrieve the identifiers for these processes by calling the EnumProcesses function. This function fills an array of DWORD values with the identifiers of all processes in the system.
Many functions in PSAPI require a process handle. To obtain a process handle for a running process, pass its process identifier (obtained from EnumProcesses) to the OpenProcess function. Remember to call the CloseHandle function when you are finished with the process handle.