Test. CS
<Br/> using system; <br/> using system. drawing; <br/> using system. windows. forms; <br/> using system. runtime. interopservices; <br/> using system. reflection; </P> <p> namespace colorcursor <br/> {<br/> /// <br/> <summary> // function of this example: <br/> // In. net to achieve the color cursor, animation cursor and custom cursor. <Br/> // </Summary> <p> public class form1: system. windows. forms. form <br/> {<br/> [dllimport ("user32.dll")] <br/> Public static extern intptr loadcursorfromfile (string filename ); </P> <p> [dllimport ("user32.dll")] <br/> Public static extern intptr setcursor (intptr cursorhandle ); </P> <p> [dllimport ("user32.dll")] <br/> Public static extern uint destroycursor (intptr cursorhandle ); </P> <p> [stathread] <br/> static void main () <br/>{< br/> application. run (New form1 (); <br/>}</P> <p> Public form1 () <br/>{< br/> This. TEXT = "Welcome to [Meng xianhui wonderful world]: http://dotnet.aspx.cc/"; <br/> cursor mycursor = new cursor (cursor. current. handle); <br/> // dinateu2.ani is a Windows cursor: <br/> intptr colorcursorhandle = loadcursorfromfile (@ "C: \ winnt \ cursors \ dinateu2.ani "); <br/> mycursor. getType (). invokemember ("handle", bindingflags. public | <br/> bindingflags. nonpublic | bindingflags. instance | <br/> bindingflags. setfield, null, mycursor, <br/> new object [] {colorcursorhandle}); <br/> This. cursor = mycursor; <br/>}< br/>}