home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- Path: 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
-
- 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
-