Unloading "load-time dynamic linked" DLLs

I have created a DLL (say A.DLL) which loads another DLL (say B.DLL) dynamically using LoadLibrary call. B.DLL loads several other DLLs (say C.DLL, D.DLL ... so on) at load time. When I call FreeLibrary in A.DLL to unload the B.DLL, the DLLs C.DLL, D.DLL, .... are not unloaded. How do I unload these libraries?
sridhar_dvjsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
luisrConnect With a Mentor Commented:
You could call GetModuleHandle("dll") and the FreeLibrary on that handle. That will unload the DLL.
0
 
pellepCommented:
I suggest you free c.dll, d.dll etc in the b.dll. i.e in the destructor or ExitInstance or in the
DllEntryPoint()/DLL_PROCESS_DETACH
of the b.dll you should free any library it loaded. this is can't
be done by a.dll, since you loaded the c and d.dll explicitly.

0
 
sridhar_dvjsAuthor Commented:
C.DLL, D.DLL etc.. are not explicitly loaded by B.DLL (they are loaded at load time not run time!!) The only explicit load is B.DLL and I am calling FreeLibrary to unload it.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
sridhar_dvjsAuthor Commented:
I thought I already rejected AlexVirochovsky's answer. The suggested code in Q10097274 can not work on WIN32. The function GetModuleUsage is absolete. All my DLLs are WIN32 and I am using MSVC 5.0 on NT 4 Sp3.
0
 
sridhar_dvjsAuthor Commented:
Please refer Q.10120210
0
All Courses

From novice to tech pro — start learning today.