<!-- Download Links -->
<!-- Add the rest of your HTML here -->
My project needs to manage a large set of DLLs. All of them export a same
set of functions. None of them link with the main project at compile time.
We call them PlugIns. These plugins are used to extend the ability of the main
program. Once they are copied into the program directory, the program can use
them, and if they are removed from the directory, the main program works just
fine, except that some functions cannot be used.
Since these DLLs are not available at the time that the main program is
we have to use LoadLibrary, GetProcAddress and FreeLibrary to use these DLLs.
It's really boring! I needed a class to ease this job. In fact, these DLLs looks
just like classes (they all have the same interface: a set of functions). Using
a class to wrap these DLLs is just reasonable.
Here comes the class CDLLModule. This class is only for deriving. Let's see
how to use it first. Suppose you have a DLL which export two functions like
int WINAPI GetEngine(char *szEngineType, char *szEngineVersion);
int WINAPI StartEngine(HWND hWnd);
The wrapper class would like this:
class CMyClass : public CDLLModule
GetEngine, (char *, char *))
GetEngine, (char *, char *), "GetEngine")
StartEngine, (HWND), "StartEngine")
Then we can use it like this:
I should explain it in more detail, but I am really not good at English. Anyway,
the code is very simple, only 64 lines including comments. I think it's very
useful, and I hope you think so too.
One last thing. It's a good idea to check the validation of the function before
calling. In another word, if you are not sure that all functions are exported
well from the DLL, Call it like this:
26 Jun 2002 - Initial Revision