The following is a complete example. You can use the command line compilation to see the effect.
Test. cs
Using System; using System. drawing; using System. windows. forms; using System. runtime. interopServices; using System. reflection; namespace ColorCursor {// <summary> /// function of this example: // In. NET to achieve the color cursor, animation cursor and custom cursor. /// </Summary> public class Form1: System. windows. forms. form {[DllImport ("user32.dll")] public static extern IntPtr LoadCursorFromFile (string fileName); [DllImport ("user32.dll")] public static extern IntPtr SetCursor (IntPtr cursorHandle ); [DllImport ("user32.dll")] public static extern uint DestroyCursor (IntPtr cursorHandle); [STAThread] static void Main () {Application. run (new Form1 ();} public Form1 () {this. text = "Welcome to [Meng xianhui wonderful world]: http://dotnet.aspx.cc/"; Cursor myCursor = new Cursor (Cursor. current. handle); // dinateu2.ani is the windows built-in cursor: IntPtr colorCursorHandle = LoadCursorFromFile (@ "C: WINNTCursorsdinosau2.ani"); myCursor. getType (). invokeMember ("handle", BindingFlags. public | BindingFlags. nonPublic | BindingFlags. instance | BindingFlags. setField, null, myCursor, new object [] {colorCursorHandle}); this. cursor = myCursor ;}}}