如何获取当前的GLOBAL鼠标光标类型(沙漏/箭头/ ..)?在Windows中.
全球 - 我需要它,即使鼠标是我的应用程序的外部,或者即使我的程序是windlowless.
在C#,Delphi或纯winapi,没关系......
非常感谢你提前!!
要获取有关全局游标的信息,请使用GetCursorInfo.
经过多年的时间回答我自己的问题.以下是检查C#中当前全局光标是否为沙漏的方法(如果需要,可以根据自己的需要扩展代码):
private static bool IsWaitCursor() { var h = Cursors.WaitCursor.Handle; CURSORINFO pci; pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); GetCursorInfo(out pci); return pci.hCursor == h; } [StructLayout(LayoutKind.Sequential)] struct POINT { public Int32 x; public Int32 y; } [StructLayout(LayoutKind.Sequential)] struct CURSORINFO { public Int32 cbSize; // Specifies the size, in bytes, of the structure. // The caller must set this to Marshal.SizeOf(typeof(CURSORINFO)). public Int32 flags; // Specifies the cursor state. This parameter can be one of the following values: // 0 The cursor is hidden. // CURSOR_SHOWING The cursor is showing. public IntPtr hCursor; // Handle to the cursor. public POINT ptScreenPos; // A POINT structure that receives the screen coordinates of the cursor. } [DllImport("user32.dll")] static extern bool GetCursorInfo(out CURSORINFO pci);