The information in this article applies to:
SUMMARYDuring development, dynamic-link libraries (DLLs) can sometimes be left in memory with no applications using them. To unload DLLs that have been left in memory, developers must exit and then restart Windows, which can be very inconvenient. DLL UNLOADER is a sample Windows-based application that lets developers select a DLL, show information about it, and unload it from the system if desired; this eliminates the need to restart Windows. MORE INFORMATIONThe following file is available for download from the Microsoft
Download Center. Click the file name below to download the file: Unloader.exeFor more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. There are two ways that a DLL can be left in memory after all applications that use it have exited:
If a DLL is left in memory with no application using it, and is then recompiled and executed, the new version of the DLL will not be loaded because Windows thinks the DLL is already loaded (because the module names are the same). If you try to debug the DLL with CodeView for Windows, the source code window will display the latest version's source code; however, the old version's code, which is still in memory, will be executed. This version mismatch causes CodeView to appear to not be working properly. To resolve this problem, you must either exit and restart Windows or force Windows to unload the old version of the DLL. The DLL UNLOADER sample calls ToolHelp to obtain the list of modules currently loaded in the system. Because this list contains modules that belong to both DLLs and applications (which are tasks), DLL UNLOADER filters out the modules that belong to tasks so that they cannot be unloaded accidentally and cause the system to crash. The list box stores the module name and handle for each module that doesn't belong to a task. When the user selects a module, its handle is used to obtain information about it and/or unload it. To unload a DLL, DLL UNLOADER first calls GetModuleUsage() to retrieve its usage count and then repeatedly calls FreeLibrary() until the usage count drops to zero; then Windows unloads the DLL. To obtain information about a DLL, DLL UNLOADER calls ModuleFindHandle() and displays the information in a dialog box. Finally, DLL UNLOADER creates an .INI file in the directory where its executable file resides to remember its last position on the screen before it exits. Additional query words: 3.10 softlib UNLOADER.EXE kbFile
Keywords : kbfile kbsample kb16bitonly kbWinOS310 |
Last Reviewed: December 2, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |