EnumProcessModules

The EnumProcessModules function retrieves a handle for each module in the specified process.

BOOL EnumProcessModules(
  HANDLE hProcess,      // handle to the process
  HMODULE * lphModule,  // array to receive the module handles
  DWORD cb,             // size of the array
  LPDWORD lpcbNeeded    // receives the number of bytes returned
);
 

Parameters

hProcess
Handle to the process.
lphModule
Pointer to the array that receives the list of module handles.
cb
Specifies the size, in bytes, of the lphModule array.
lpcbNeeded
Receives the number of bytes returned in the lphModule 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 EnumProcessModules a large array of HMODULE values, because it is hard to predict how many modules there will be in the process at the time you call EnumProcessModules. To determine how many modules were enumerated by the call to EnumProcessModules, divide the resulting value in the lpcbNeeded parameter by sizeof(HMODULE).

See Also

Process Status Helper Overview, PSAPI Functions, EnumProcesses