日期:2014-05-18 浏览次数:20845 次
this.Text = "旺旺软件工作室"; Cursor myCursor = new Cursor(Cursor.Current.Handle); IntPtr colorCursorHandle = LoadCursorFromFile(@"C:\normal.cur");//鼠标图标路径 myCursor.GetType().InvokeMember("handle", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetField, null, myCursor, new object[] { colorCursorHandle }); this.Cursor = myCursor;
------解决方案--------------------
public partial class Form1 : 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); public Form1() { Cursor myCursor = new Cursor(Cursor.Current.Handle); IntPtr colorCursorHandle = LoadCursorFromFile(@"C:\001.ani"); myCursor.GetType().InvokeMember("handle", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetField, null, myCursor, new object[] { colorCursorHandle }); this.Cursor = myCursor; InitializeComponent(); } }