Microsoft KB Archive/283007

{|
 * width="100%"|

INFO: Window Class Registration and the Application's First Thread

 * }

Q283007

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * the operating system: Microsoft Windows 2000

-

SUMMARY
This article describes the behavior of window class registration in a multithreaded application.

MORE INFORMATION
When an application is started, the first thread (also referred to as the primary thread) is usually used to register custom window classes through the RegisterClassEx API.

On the first call to a Graphics Device Interface (GDI)/USER32 API function, USER32 will check to see if the call is being made on the application's first thread. If this is the case, USER32 will register all system window classes for the process and will maintain the list of classes internally, one copy per process. Additional custom registrations will be added to this list.

If the first thread is terminated, either by the main routine returning or by calling the ExitThread API, all window registrations will be removed. If ExitThread is used on the primary thread and there are child threads present, the application will not terminate and a child thread will assume the role of the application's first thread. If another GDI/USER32 API call is made from this new first thread, USER32 will reregister all system window classes again. However, custom class registrations will no longer be available.