日期:2014-05-17 浏览次数:21291 次
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetForegroundWindow")]
public static extern IntPtr GetForegroundWindow();
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetWindowRect")]
public static extern int GetWindowRect(IntPtr hwnd, ref System.Drawing.Rectangle lpRect);
private static void TestGetForegroundWindowRectangle()
{
IntPtr hForeground = GetForegroundWindow();
System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
GetWindowRect(hForeground, ref rect);
//这里的rect就是你你要的
}