[StructLayout(LayoutKind.Sequential)]
public struct POINTAPI
{
public int x;
public int y;
}
[DllImport("user32.dll", EntryPoint="GetCursorPos")]
public static extern int GetCursorPos (ref POINTAPI lpPoint);
POINTAPI point = new POINTAPI();
int i = GetCursorPos( ref point);
具体实现方法:
步骤一:
在使用的窗体里声明一个类:
public class GetCurPos
{
[DllImport("user32.dll")]
public static extern short GetCursorPos(ref System.Drawing.Point point);
}