Interlinked dll's

Started by
2 comments, last by Floating 20 years ago
Hi, I have a whole application which builds into a single dll. However I want my dll to be split into many sub-dlls for better maintenance. The thing I was thinking of is following: If I have for instance: dll1 --> dll2 --> dll3 dll1 --> dll3 where --> means "depends on" Then wouldn''t I have redundant information in memory? (dll3 loaded 2 times?) This was the first part of my question. The second part: can a dll export classes? If yes how is this done and is all class information of the exported class available while programming? (sub-classes are also recognized by the developpment ebvironment) Thanks
Advertisement
Quoting from MSDN, Platform SDK, to answer your first question:
"If the call to LoadLibrary or LoadLibraryEx specifies a DLL whose code is already mapped into the virtual address space of the calling process, the function simply returns a handle to the DLL and increments the DLL reference count. Note that two DLLs that have the same base file name and extension but are found in different directories are not considered to be the same DLL."

As for the second question, search the MSDN for AFX_EXT_CLASS macro description.
Also, you can of course implement class factory-type functions (functions that return object instances and handle their reference counts and eventual deletion) in the dll.

-Nik

EDIT: By the way, the macro seems to simply expand to "__declspec(dllexport)" Live and learn!

EDIT2: MSDN article "Importing into an Application Using __declspec(dllimport)" is also good read, when you want to actually use the exported classes in other programs.

[edited by - Nik02 on April 14, 2004 3:15:50 AM]

Niko Suni

Thanks a lot for your reply Nik02!

About my first problem, I am not using LoadLibrary nor LoadLibraryEx, my dlls are statically linked. But I guess same will happen.
When the libraries are linked statically, Windows loads and maps the dll:s for your application, therefore performing essentially the same steps as LoadLibrary(Ex). I believe that the behavior of the loader is exactly the same in that case (someone please correct me if I''m wrong).
Glad I could help

-Nik

Niko Suni

This topic is closed to new replies.

Advertisement