I'm working on a program with a plugin-based architecture. All the plugins are DLLs, and some of them can have dependencies on other plugin DLLs. I'd like to be able to do the following:
- At program startup time, scan the plugins folder.
- For each plugin found, check if that plugin is already loaded. (Which it could be, if a previously-loaded plugin caused it to be loaded as a dependency).
- If not, load it.
The first and third steps are trivial, but how do I do the second? Is there a winapi call that, given a filename of a DLL, will tell me if that DLL is currently loaded into the current process? (Or perhaps one that takes a filename and a process handle?)
Please, no answers saying "just load it anyway." I know that will work. I'm trying to avoid that.