Global Classes in Win32

Last reviewed: November 2, 1995
Article ID: Q80382
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

Under 16-bit Windows, when an application wants to check whether or not a window class has been previously registered in the system, it typically checks hPrevInstance. Under 32-bit Windows and Windows NT, hPreviousInstance is always FALSE, because a class definition is not available outside the process context of the process that registers it. Thus, code that checks hPreviousInstance will always register the window class.

MORE INFORMATION

Under 32-bit Windows and Windows NT, a style of CS_GLOBALCLASS indicates that the class is available to every DLL in the process, not every application and DLL in the system, as it does in Windows 3.1.

To have a class registered for every process in the system under Windows NT:

  1. Register the class in a DLL.

  2. Use a style of CS_GLOBALCLASS.

  3. List the DLL in the following registry key.

    HKEY_LOCAL_MACHINE\S OFTWARE\

          Microsoft\
          Windows NT\
          CurrentVersion\
          Windows\
          AppInit_DLLs
    

This will force the DLL to be loaded into every process in the system, thereby registering the class in each and every process.

NOTE: This technique does not work under Windows 95.

For more information, please see "Window Classes in Win32," which is available on the MSDN CD, starting April 1994.


Additional reference words: 3.10 3.50 4.00 95
KBCategory: kbui
KBSubcategory: UsrCls


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: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.