更换系统鼠标指针
我想用c#代码实现更改桌面背景和系统鼠标的图片请各位指点 --------------------编程问答-------------------- 用文件复制覆盖原图片不行吗 --------------------编程问答-------------------- UP --------------------编程问答-------------------- 找找API函数吧. --------------------编程问答-------------------- ,接分 --------------------编程问答-------------------- 给个更改鼠标指针的的类给你看看public class CursorsStyle
{
[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);
[DllImport("User32.DLL")]
public static extern bool SetSystemCursor(IntPtr hcur, uint id);
[DllImport("User32.DLL")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam,
IntPtr pvParam, uint fWinIni);
public const uint OCR_NORMAL = 32512;
public const uint OCR_IBEAM = 32513;
public const uint OCR_WAIT=32514;
public const uint OCR_CROSS = 32515;
public const uint OCR_UP = 32516;
public const uint OCR_SIZE = 32640;
public const uint OCR_ICON = 32641;
public const uint OCR_SIZENESE =32642;
public const uint OCR_SIZENESW = 32643;
public const uint OCR_SIZEWE = 32644;
public const uint OCR_SIZENS = 32645;
public const uint OCR_SIZEALL= 32646;
public const uint OCR_ICOCUR= 32647;
public const uint OCR_NO = 32648;
public const uint OCR_HAND = 32649;
public const uint SPI_SETCURSORS = 87;
public const uint SPIF_SENDWININICHANGE = 2;
/// <summary>
/// 设置当前的窗体的鼠标样式
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static Cursor CurrentCursorStyle(string fileName)
{
Cursor cursor = new Cursor(Cursor.Current.Handle);
IntPtr colorCursorHandle = CursorsStyle.LoadCursorFromFile(fileName);
cursor.GetType().InvokeMember("handle", BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.SetField, null, cursor,
new object[] { colorCursorHandle });
return cursor;
}
/// <summary>
/// 设置操作系统的鼠标样式
/// </summary>
/// <param name="fileName"></param>
public static void SystemCursorStyle(string fileName)
{
Cursor cursor2 = CurrentCursorStyle(fileName);
SetSystemCursor(cursor2.Handle, OCR_NORMAL);
}
/// <summary>
/// 还原操作系统的鼠标样式
/// </summary>
public static void BackCursor()
{
SystemParametersInfo(SPI_SETCURSORS, 0, IntPtr.Zero, SPIF_SENDWININICHANGE);
}
} --------------------编程问答-------------------- 5楼正解
补充:.NET技术 , C#