Article View: comp.os.ms-windows.programmer.misc
Article #1758Re: Force DLL to unload
From: Neil Galarneau
Date: Tue, 22 Dec 1992 18:15
Date: Tue, 22 Dec 1992 18:15
40 lines
1686 bytes
1686 bytes
flc@mips.com (Fred Cox) writes:
>mccreary@sword.eng.hou.compaq.com (Ed McCreary) writes:
>>In article <DEREKL.92Dec18100741@watson.harlqn.co.uk> derekl@harlqn.co.uk (Derek Law) writes:
>>>Does anybody know how to FORCE Windows 3.1 to unload a DLL? I'm
>>>developing a DLL, but every time I change it I have to quit and
>>>restart Windows - otherwise Windows complains that the file is "still
>>>in use" and so write protected.
>>>
>>How are you loading it? Try this...
>>hLib = LoadLibrary("MY.DLL");
>>....program code....
>>FreeLibrary(hLib);
>That works for when your DLL works, but when you get a UAE, the thing
>doesn't get FreeLibraried, and you're hosed.
[lines deleted...]
>Fred Cox
>flc@mti.sgi.com
Windows keeps a use count on dlls. The use count gets incremented on
LoadLibrary and decremented on FreeLibrary. When the use count drops to zero
the dll is unloaded.
If your app UAEs, it never does the FreeLibrary, and any new dll you try to
make is ignored.
The solution is to write a trivial program that does:
while(GetModuleUsage(hLib))
FreeLibrary(hLib);
Neil
neil@progress.com
Technical Details
Message-ID:
<1992Dec22.181551.18576@progress.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!ames!agate!linus!progress!neilReferences:
<DEREKL.92Dec18100741@watson.harlqn.co.uk> <1992Dec18.144024.14800@twisto.eng.hou.compaq.com> <flc.724728723@poseidon>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!ames!agate!linus!progress!neil From: neil@progress.COM (Neil Galarneau) Subject: Re: Force DLL to unload Message-ID: <1992Dec22.181551.18576@progress.com> Sender: usenet@progress.com (Mr. Usenet) Nntp-Posting-Host: pinta Organization: Progress Software Corp. References: <DEREKL.92Dec18100741@watson.harlqn.co.uk> <1992Dec18.144024.14800@twisto.eng.hou.compaq.com> <flc.724728723@poseidon> Date: Tue, 22 Dec 1992 18:15:51 GMT Lines: 40