?
Solved

Unloading "load-time dynamic linked" DLLs

Posted on 1999-01-22
6
Medium Priority
?
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

771 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