Platform SDK: Performance Monitoring |
The EnumProcessModules function retrieves a handle for each module in the specified process.
BOOL EnumProcessModules( HANDLE hProcess, // handle to process HMODULE *lphModule, // array of module handles DWORD cb, // size of array LPDWORD lpcbNeeded // number of bytes required );
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 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 if the lphModule array is too small to hold all module handles for the process, compare the value returned in lpcbNeeded with the value specified in cb. If lpcbNeeded is greater than cb, increase the size of the array and call EnumProcessModules again.
To determine how many modules were enumerated by the call to EnumProcessModules, divide the resulting value in the lpcbNeeded parameter by sizeof(HMODULE).
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, EnumProcesses