PRB: Cannot Exit Windows with DLL-Instanced Windows Open

Last reviewed: April 4, 1995
Article ID: Q68552
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.1 and 3.0

SYMPTOMS

When the user closes the Windows Program Manager and chooses the OK button in the Exit Windows dialog box, Windows does not close.

CAUSE

A window was created in a window class registered by a dynamic-link library (DLL), and the DLL was unloaded from the system before the window was destroyed.

RESOLUTION

Before the DLL is unloaded from the system, explicitly destroy all windows created in a window class registered by the DLL.

MORE INFORMATION

When a DLL is unloaded from memory, all window classes registered by that DLL are purged. Any windows that have been created with a DLL- registered window class become invalid when the window class is purged; however, these windows are not destroyed.

Sending any message to an invalid window returns zero. When Windows sends a WM_QUERYENDSESSION message to an invalid window, the window returns zero and Windows does not shut down. Under the debugging version of Windows, this action creates Fatal Exit code 0x0007 messages.

This problem does not occur under Windows 3.1. When a DLL is unloaded, before its window classes are purged, any windows created using a DLL- registered window class are destroyed. When the debugging version of Windows 3.1 destroys a window in this manner, it produces one of the following four messages:

  • Module unloaded with windows still subclassed
  • Global class freed with existent class windows!
  • Window class freed with existent class windows!
  • USER: Window not destroyed


Additional reference words: 3.00 3.10
KBCategory: kbprg kbprb
KBSubcategory: KrDll


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 4, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.