RegisterClass

The RegisterClass function registers a window class for subsequent use in calls to the CreateWindow or CreateWindowEx function.

The RegisterClass function has been superseded by the RegisterClassEx function. You can still use RegisterClass, however, if you do not need to set the class small icon.

ATOM RegisterClass(
  CONST WNDCLASS *lpWndClass   // address of structure with class 
                               // data
);
 

Parameters

lpWndClass
Pointer to a WNDCLASS structure. You must fill the structure with the appropriate class attributes before passing it to the function.

Return Values

If the function succeeds, the return value is an atom that uniquely identifies the class being registered.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

If you register the window class by using RegisterClassA, the application tells the system that the windows of the created class expect messages with text or character parameters to use the ANSI character set; if you register it by using RegisterClassW, the application requests that the system pass text parameters of messages as Unicode. The IsWindowUnicode function enables applications to query the nature of each window. For more information on ANSI and Unicode functions in the Win32 API, see Function Prototypes.

All window classes that an application registers are unregistered when it terminates.

Windows 95: All window classes registered by a DLL are unregistered when the DLL is unloaded.

Windows NT: No window classes registered by a DLL are unregistered when the DLL is unloaded.

Windows 95: RegisterClass fails if the cbWndExtra or cbClsExtra member of the WNDCLASS structure contains more than 40 bytes.

Windows CE: The WNDCLASS structure pointed to by the lpWndClass parameter does not support the lpszMenuName field because Windows CE does not support default menus.

Unless you are using the Windows CE Iconcurs component, which provides mouse cursor support on appropriate target platforms, you cannot use the hCursor field in the WNDCLASS structure pointed to by lpWndClass.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also

Window Classes Overview, Window Class Functions, CreateWindow, CreateWindowEx, GetClassInfo, GetClassName, RegisterClassEx, UnregisterClass, WindowProc, WNDCLASS