Solved

Unloading "load-time dynamic linked" DLLs

Posted on 1999-01-22
6
266 Views
Last Modified: 2010-04-02
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?
0
Comment
Question by:sridhar_dvjs
6 Comments
 
LVL 4

Expert Comment

by:pellep
ID: 1184829
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
 

Author Comment

by:sridhar_dvjs
ID: 1184830
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
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1184831
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:sridhar_dvjs
ID: 1184832
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
 
LVL 3

Accepted Solution

by:
luisr earned 20 total points
ID: 1184833
You could call GetModuleHandle("dll") and the FreeLibrary on that handle. That will unload the DLL.
0
 

Author Comment

by:sridhar_dvjs
ID: 1184834
Please refer Q.10120210
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now