How to know if a given DLL is loaded by a given process? [duplicate]
Possible Duplicate:
How to programmatically get DLL dependencies
On Windows, in a C++ program, I want to know if a given DLL (I know the path) is loaded by a 开发者_JAVA百科given external process (I know the path of the exe), using win32 functions. It must be possible to list all DLLs loaded by a process, as process explorer does.
Fabien
First you have get the ID of the Process you are looking for. Use the EnumProcesses function described here to find your desired process. There is a nice example provided to list all processes and their names, that you can use as a starting point.
As the second step you can list all of the modules, that is the DLLs loaded by each process. Use the EnumProcessModules function.
This example does mostly what you want, you only need to add some more check code to filter for your process and your module.
精彩评论