Function Reference


Retrieves a handle and name for each module in the specified process

#include <WinAPIProc.au3>
_WinAPI_EnumProcessModules ( [$iPID = 0 [, $iFlag = 0]] )


$iPID [optional] The PID of the process. Default (0) is the current process.
$iFlag [optional] The filter criteria. This parameter is valid only for Windows Vista or later, and can be one of the following values:

Return Value

Success: The 2D array containing the following information:
    [0][0] - Number of rows in array (n)
    [0][1] - Unused
    [n][0] - Handle to the module.
    [n][1] - The path to the file that contains the module.
Failure: Sets the @error flag to non-zero.


This function does not retrieve handles for modules that were loaded with the $LOAD_LIBRARY_AS_DATAFILE flag.
For more information, see _WinAPI_LoadLibraryEx().

Do not call _WinAPI_CloseHandle() on any of the handles returned by this function.
The information comes from a snapshot, so there are no resources to be freed.

If _WinAPI_EnumProcessModules() is called from a 32-bit application running on WOW64, it can only enumerate the modules of a 32-bit process.
If the process is a 64-bit process, this function fails and the last error code is ERROR_PARTIAL_COPY (299).

See Also

Search EnumProcessModulesEx in MSDN Library.


#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

If (_WinAPI_GetVersion() < '6.0') And (@AutoItX64) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'This example works from a 64-bit system only in Windows Vista or later.')

Local $aData = _WinAPI_EnumProcessModules()

_ArrayDisplay($aData, '_WinAPI_EnumProcessModules')