1

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 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

Community
  • 1
  • 1
Fabien
  • 6,700
  • 7
  • 35
  • 35
  • 4
    Isnt it almost similar to this? http://stackoverflow.com/questions/450039/how-to-programmatically-get-dll-dependencies – vpram86 Oct 12 '09 at 09:40
  • 450039 talks about static analysis this one about dyanmic, but the answer at 450039 is for both cases. – Shay Erlichmen Oct 12 '09 at 09:53

1 Answers1

3

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.

Frank Bollack
  • 24,478
  • 5
  • 49
  • 58