RegisterClassW function (winuser.h)
Registers a window class for subsequent use in calls to the CreateWindow or CreateWindowEx function.
Syntax
ATOM RegisterClassW(
[in] const WNDCLASSW *lpWndClass
);
Parameters
[in] lpWndClass
Type: const WNDCLASS*
A pointer to a WNDCLASS structure. You must fill the structure with the appropriate class attributes before passing it to the function.
Return value
Type: ATOM
If the function succeeds, the return value is a class atom that uniquely identifies the class being registered. This atom can only be used by the CreateWindow, CreateWindowEx, GetClassInfo, GetClassInfoEx, FindWindow, FindWindowEx, and UnregisterClass functions and the IActiveIMMap::FilterClientWindows method.
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, see Conventions for Function Prototypes.
All window classes that an application registers are unregistered when it terminates.
No window classes registered by a DLL are unregistered when the DLL is unloaded. A DLL must explicitly unregister its classes when it is unloaded.
Examples
For an example, see Associating a Window Procedure with a Window Class.
Note
The winuser.h header defines RegisterClass as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
API set | ext-ms-win-ntuser-windowclass-l1-1-0 (introduced in Windows 8) |
See also
Conceptual
Reference