1

I like to change the Cursor like i do in autoit with this syntax:

DllCall($user32, 'int', 'LoadCursorFromFile', 'str', 'data\Cursors\rotmg.cur')

Does someone know how to do that in C#?

CptVince
  • 89
  • 1
  • 9

1 Answers1

1

You need to use PInvoke/DLLImport to make Windows API calls.

From PInvoke.NET, the declaration would be:

[DllImport("user32.dll")]
static extern IntPtr LoadCursorFromFile(string lpFileName);

And sample use:

IntPtr colorCursorHandle = LoadCursorFromFile("c:\\temp.cur");
Cursor myCursor = new Cursor(colorCursorHandle);
this.Cursor = myCursor;

PInvoke.NET is a good resource for getting the correct function signatures of PInvoke calls and structure marshalling.

BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117