In a nutshell: I want to do the same thing \"Dependency Walker\" does.
Is there any Win32 API function which can enumerate the dependencies of a EXE and/or DLL file?
It seems that Dependency Walker source code itself was given by Microsoft via MSJ. Please look at Re: [DUG]: Dependency Walker.
You need to refer some other site to download since the link given in this mail trail is not working.
Please check MSJ Source Code Updates: Since I don't have time, I have not checked whether it contains source code or only EXE foæes.
The following commands dumps the direct dependencies of some.exe :
dumpbin /imports some.exe
It works on DLLs too.
This won't list dependencies such as plugins loaded at application launch (via LoadLibrary calls). Same for COM dependencies since they work the same way (as far as I know).
If you need to know all the DLLs used by a running program, use ProcessExplorer.
Run up the application, with Process Explorer already running and set to filter for your applications .exe name.
There is no way to detect all COM dependencies that an executable has without running it.
You probably need to walk the executable's file structure to work this out programatically. Therefore something like the 'PE Dump' program that's mentioned here: http://msdn.microsoft.com/en-gb/magazine/cc301808.aspx would be a good starting point. The actual code that you need can be found here: http://www.wheaty.net/downloads.htm
User @blue... eluded to Dependency Walker. When using Dependency Walker, after opening the file you can see the base requirements that are used. Only when executing the program and exercising all of its functions can you find all of the dynamically-loaded DLLs.
Sometimes the best thing to do if you can is ask the developer what DLLs are required. An application may only load some DLLs when absolutely needed. e.g. Loading faultrep.dll, for custom Windows Error Reporting, when it is about to crash.
findstr -i .dll exe.exe | more | findstr -i .dll | more
rem :)