private static bool IsWaitCursor()
{
var h = Cursors.WaitCursor.Handle;
CURSORINFO pci;
pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
if(!GetCursorInfo(out pci))
throw new Win32Exception(Marshal.GetLastWin32Error());
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", SetLastError = true)]
static extern bool GetCursorInfo(out CURSORINFO pci);
3条答案
按热度按时间mccptt671#
多年后,是时候回答我自己的问题了。下面是如何在C#中检查当前全局光标是否是沙漏的(如果需要,可以根据自己的需要扩展代码):
5vf7fwbs2#
要获取有关全局游标的信息,请使用GetCursorInfo。
vaj7vani3#
使用(在Delphi中)
用于当前鼠标光标的。
General Win32(用户32)提供:
这应该适用于其他Win32语言。