3 out of 8 rated this helpful - Rate this topic

LoadCursorFromFile function

Applies to: desktop apps only

Creates a cursor based on data contained in a file.

Syntax

HCURSOR WINAPI LoadCursorFromFile(
  __in  LPCTSTR lpFileName
);

Parameters

lpFileName [in]

Type: LPCTSTR

The source of the file data to be used to create the cursor. The data in the file must be in either .CUR or .ANI format.

If the high-order word of lpFileName is nonzero, it is a pointer to a string that is a fully qualified name of a file containing cursor data.

Return value

Type: HCURSOR

If the function is successful, the return value is a handle to the new cursor.

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

Return codeDescription
ERROR_FILE_NOT_FOUND

The specified file cannot be found.

 

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

LoadCursorFromFileW (Unicode) and LoadCursorFromFileA (ANSI)

See also

Reference
LoadCursor
SetCursor
SetSystemCursor
Conceptual
Cursors

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Do not DestroyCursor() it!
This function creates a shared cursor, which means that it must not be deleted by DestroyCursor().
See DestroyCursor(): http://msdn.microsoft.com/en-us/library/ms648386%28v=vs.85%29.aspx
To load a non-shared cursor from a file, use LoadImage() with IMAGE_CURSOR and LR_LOADFROMFILE, and without LR_SHARED.
See LoadImage(): http://msdn.microsoft.com/en-us/library/ms648045%28v=vs.85%29.aspx
C# Signature
[dllImport("user32.dll")]
static extern Intptr LoadCursorFromFile(String lpFileName)


Example:

Intptr cursorHandle =LoadCursorFromFile("D:\\animatedCursor.cur");

//create new cursor from handle

Cursor newCursor=new Cursor(cursorHandle);

//Set cursor
this.cursor=newCursor;