The LoadCursor function loads the specified cursor resource from the executable (.EXE) file associated with an application instance.
Syntax
HCURSOR LoadCursor( HINSTANCE hInstance, LPCTSTR lpCursorName );
Parameters
hInstance [in] Handle to an instance of the module whose executable file contains the cursor to be loaded. lpCursorName [in] Pointer to a null-terminated string that contains the name of the cursor resource to be loaded. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. The MAKEINTRESOURCE macro can also be used to create this value. To use one of the predefined cursors, the application must set the hInstance parameter to NULL and the lpCursorName parameter to one the following values: IDC_APPSTARTINGStandard arrow and small hourglassIDC_ARROWStandard arrowIDC_CROSSCrosshairIDC_HANDWindows 98/Me, Windows 2000/XP: HandIDC_HELPArrow and question markIDC_IBEAMI-beamIDC_ICONObsolete for applications marked version 4.0 or later.IDC_NOSlashed circleIDC_SIZEObsolete for applications marked version 4.0 or later. Use IDC_SIZEALL.IDC_SIZEALLFour-pointed arrow pointing north, south, east, and westIDC_SIZENESWDouble-pointed arrow pointing northeast and southwestIDC_SIZENSDouble-pointed arrow pointing north and southIDC_SIZENWSEDouble-pointed arrow pointing northwest and southeastIDC_SIZEWEDouble-pointed arrow pointing west and eastIDC_UPARROWVertical arrowIDC_WAITHourglass
IDC_APPSTARTING
IDC_ARROW
IDC_CROSS
IDC_HAND
IDC_HELP
IDC_IBEAM
IDC_ICON
IDC_NO
IDC_SIZE
IDC_SIZEALL
IDC_SIZENESW
IDC_SIZENS
IDC_SIZENWSE
IDC_SIZEWE
IDC_UPARROW
IDC_WAIT
Return Value
If the function succeeds, the return value is the handle to the newly loaded cursor.If the function fails, the return value is NULL. To get extended error information, call GetLastError.
If the function succeeds, the return value is the handle to the newly loaded cursor.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
The LoadCursor function loads the cursor resource only if it has not been loaded; otherwise, it retrieves the handle to the existing resource. This function returns a valid cursor handle only if the lpCursorName parameter is a pointer to a cursor resource. If lpCursorName is a pointer to any type of resource other than a cursor (such as an icon), the return value is not NULL, even though it is not a valid cursor handle. The LoadCursor function searches the cursor resource most appropriate for the cursor for the current display device. The cursor resource can be a color or monochrome bitmap. Windows 95/98/Me: LoadCursorW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
The LoadCursor function loads the cursor resource only if it has not been loaded; otherwise, it retrieves the handle to the existing resource. This function returns a valid cursor handle only if the lpCursorName parameter is a pointer to a cursor resource. If lpCursorName is a pointer to any type of resource other than a cursor (such as an icon), the return value is not NULL, even though it is not a valid cursor handle.
The LoadCursor function searches the cursor resource most appropriate for the cursor for the current display device. The cursor resource can be a color or monochrome bitmap.
Windows 95/98/Me: LoadCursorW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
Example
For an example, see Creating a Cursor.
Function Information
Minimum DLL Versionuser32.dllHeaderDeclared in Winuser.h, include Windows.hImport libraryUser32.libMinimum operating systems Windows 95, Windows NT 3.1UnicodeImplemented as ANSI and Unicode versions.
See Also
Cursors Overview, LoadImage, MAKEINTRESOURCE, SetCursor, SetCursorPos, ShowCursor