如果您想更改默认的鼠标光标主题:
您只需在注册表中更改它即可:
有三个主要的注册表项发挥作用。
- 注册表项 HKEY_CURRENT_USER\Control Panel\Cursors 包含活动用户光标
1a) 下面的值是不同类型的光标
1b) 方案源指定当前正在使用的游标方案的类型。
不同的值是:
“0”——Windows 默认值
“1”——用户方案
《2》——系统方案
-
注册表键值HKEY_CURRENT_USER\控制面板\光标包含用户定义的游标方案(即方案源 = 1)
-
注册表键值HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\控制面板\Schemes包含系统游标方案(即方案源 = 2)
如果您已经将路径更改为 HKCU\Control Panel\Cursors 中的一种光标类型,并意识到它没有执行任何操作。你是对的,仅仅更新一个键——例如 HKCU\Control Panel\Cursors\Arrow——是不够的。您必须告诉 Windows 加载新光标。
这就是系统参数信息 https://msdn.microsoft.com/en-us/library/ms724947.aspx要尝试一下,我们将 HKCU\Control Panel\Cursors\Arrow 更改为 C:\WINDOWS\Cursors\appstar3.ani(假设您有此图标),然后调用 SystemParametersInfo。
在 AutoHotKey 脚本中:
SPI_SETCURSORS := 0x57
result := DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS, "UInt", 0, "UInt", 0, "UInt", '0')
MsgBox Error Level: %ErrorLevel% `nLast error: %A_LastError%`nresult: %result%
翻译成 C#:
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
const int SPI_SETCURSORS = 0x0057;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDCHANGE = 0x02;
调用它:
SystemParametersInfo(SPI_SETCURSORS, 0, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
更改为默认 Windows 光标
现在是棘手的部分。如果您查看 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Schemes,您会注意到“Windows Default”被定义为“,”,或者换句话说,没有指针到实际的光标!
现在做什么?不用担心。您所要做的就是将不同的游标类型设置为空字符串,然后像往常一样进行 SystemParametersInfo 调用。事实上,您可以在任何方案中将任何光标类型设置为空字符串,Windows 会将其默认为“Windows 默认”方案中的等效项。
REF:
https://thebitguru.com/articles/programmatically-changing-windows-mouse-cursors/3 https://thebitguru.com/articles/programmatically-changing-windows-mouse-cursors/3
https://social.msdn.microsoft.com/Forums/vstudio/en-US/977e2f40-3222-4e13-90ea-4e8d0cdf289c/faq-item-how-to-change-the-systems-cursor-using-visual- cnet?forum=csharpgeneral https://social.msdn.microsoft.com/Forums/vstudio/en-US/977e2f40-3222-4e13-90ea-4e8d0cdf289c/faq-item-how-to-change-the-systems-cursor-using-visual-cnet?forum=csharpgeneral