任何人都知道为什么这不起作用?
IntPtr hWnd = FindWindow(null, "Calculator");
IntPtr hWnd2 = GetActiveWindow();
if(hWnd == hWnd2)
{
MessageBox.Show("Same");
}
调用是:
[DllImport("user32.dll")]
static extern IntPtr GetActiveWindow();
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);