Geoff Chappell - Software Analyst
BOOLEAN RegisterClassNameW (PCWSTR lpClassName);
The lpClassName argument provides the name of a window class to register.
The function returns FALSE to indicate failure. Anything else is success.
If the given name is that of a supported window class, the function registers the window class. The function succeeds if the registration succeeds or if the reason for failure is that the class is already registered.
The name is case-insensitive. The following window classes are supported:
Class | Applicable Versions |
---|---|
Button | 6.0 and higher |
ComboBox | 6.0 and higher |
ComboBoxEx32 | |
ComboLBox | 6.0 and higher |
DropDown | 6.10 and higher |
Edit | 6.0 and higher |
ImageDrag | 6.10 and higher |
ListBox | 6.0 and higher |
msctls_hotkey32 | |
msctls_progress32 | |
msctls_statusbar32 | |
msctls_trackbar32 | |
msctls_updown32 | |
NativeFntCtl | |
ReaderModeCtl | 6.0 and higher |
RebarWindow32 | |
ScrollBar | 6.0 and higher |
Static | 6.0 and higher |
SysAnimate32 | |
SysDateTimePick32 | |
SysHeader32 | |
SysIPAddress32 | |
SysLink | 6.0 and higher |
SysListView32 | |
SysMonthCal32 | |
SysPager | |
SysTabControl32 | |
SysTreeView32 | |
ToolbarWindow32 | |
tooltips_class32 |
The traditional way to ensure that the window classes for common controls are registered in advance of trying to create any controls is to call the InitCommonControlsEx function, with flags to specify which controls are wanted. Though this remains a valid technique, it is made redundant by RegisterClassNameW. However, the mechanism of redundancy is not that arbitrary COMCTL32 clients may call RegisterClassNameW instead of InitCommonControlsEx (which would not be redundancy, but inferior replacement). The mechanism is instead that RegisterClassNameW may be called by USER32 during an attempt to create a window whose class is not yet registered. If the current activation context specifies the class as requiring redirection to some module, then USER32 calls that module’s RegisterClassNameW function to get the class registered before proceeding to create the window.
Note that the RegisterClassNameW function is not specific to COMCTL32. It can usefully be implemented by any assembly whose manifest has a windowClass element. It happens that the only such assembly in the Windows Vista package is COMCTL32 and that COMCTL32 is the only exporter of the RegisterClassNameW function.
The RegisterClassNameW function is exported by name from COMCTL32.DLL in some builds of versions 5.82 and 6.0, and higher:
No reason is presently known that this function is dropped from Windows XP SP3.
Though this function dates from 2003, it was still not documented by Microsoft as late as the January 2007 edition of the Software Development Kit (SDK) for Windows Vista.