|
-
July 16th, 2003, 11:28 AM
#1
LoadLibrary and FreeLibrary in DLL
I have a small problem with LoadLibrary and FreeLibrary in my DLL. For compatibility reason with all WIN OS versions I'm not linking neccessary libraries, but I load them on very begining in entry-point function and getting procedures addresses. It works fine, but it isn't recommended, based on info in MSDN ( You must not call LoadLibrary it says, because you may create dependency loops in the DLL load order ).
Problem with LoadLibrary function can be fixed easily, but how to use FreeLibrary at the end. Idea like load libraries in every exported functions and then unload at the end don't looks to be like very best solution. What is the proper way to unload libraries if I can't do that in DLL_PROCESS_DETACH in entry-point. I didn't find any info how to do it.
-
July 24th, 2003, 07:42 AM
#2
How about having a global object in your library containing exported functions and calling the FreeLibrary in the destructor of this global object. Since the destructors for the global objects are called only at the time of dll being unloaded you can ensure that there are no outstanding function calls.
But I haven't tried this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|