I am developing an application that needs to read in several file formats and merge the data. Because we may want to support additional formats in the future, the file readers have to be developed as DLLs, and loaded at runtime based on user input. I will normally be loading two DLLs at a time.
I was thinking that I could create an Abstract Interface (Like this), but if I use a factory function in each of my (subclassed) DLL classes, when I load two DLLs, the two function definitions will interfere with each other. Am I missing something? Is there a better way to do this?
Thanks!
(upgraded from comment)
If you load the DLLs with LoadLibrary you get a handle to the DLL – which you must later use in FreeLibrary to unload the DLL!
After acquiring the handle you can call GetProcAddress to get a pointer to the function.
sample code:
As I already mentioned in the comment: NEVER EVER RELEASE MEMORY ALLOCATED IN A DLL FROM ANOTHER CONTEXT (other DLL or the EXE)!