I'm having problems with dynamically allocated Objects being distroyed once the DLL is freed.
I have a DLL which gets passed a TStringList as one of it's parameters. I dynamically create objects (of type TObject) and add these to the Object Property of the TStringList using TStringList.AddObject. I load in the DLL from the main application using LoadLibrary and free it using FreeLibrary. Once I return from the DLL and free it, I can not access the Objects of the TStringList. When I try to access the objects, I get an Access Violation. From this I assume that the objects are being freed along with the DLL.
I'm already using ShareMem in the DLL's Uses section and in my main application Uses section. From what I've read about this, it allocates memory from the Global Heap thus giving other modules access to it but this is not what appears to be happening.
What I need to know is if there is any way to create Objects in the DLL which the main application can gain access to after the DLL has been freed?
Note : It is not pratical to keep the DLL open until I exit the main application as I will have many DLL's loaded at the same time.
Please Help. Thanks.