Skip to content

C# WindowFromPoint在64位程序中无效

L edited this page Dec 28, 2021 · 4 revisions

WindowFromPoint() 不需要两个参数,它只需要一个,POINT类型的结构。
在32位程序中可以以不同的方式传递参数,在64位模式下则不行,所以以下写法无效。

[DllImport("user32.dll")]
public static extern IntPtr WindowFromPoint(int xPoint, int yPoint);

正确写法如下:
Point=System.Drawing.Point

[DllImport("user32.dll")]
public static extern IntPtr WindowFromPoint(System.Drawing.Point point);

参考资料

WindowFromPoint doesn't work correctly on 64bit .NET Framework
WindowFromPoint function (winuser.h)
Create pageWindowFromPoint (user32)

Clone this wiki locally