PRB: Cannot Exit Windows with DLL-Instanced Windows Open

ID Number: Q68552

3.00 3.10

WINDOWS

Summary:

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

Explicitly destroy all windows created in a window class registered

by a DLL before the DLL is unloaded from the system.

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