[DllImport("User32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
private void button1_Click(object sender, EventArgs e)
{
IntPtr ParenthWnd = new IntPtr(0);
ParenthWnd = FindWindow(null, "计算器");
//判断这个窗体是否有效
if (ParenthWnd != IntPtr.Zero)
{
MessageBox.Show("找到窗口");
}
else
MessageBox.Show("没有找到窗口");
}
各种软件窗体 IE窗体等等!!(只要是在任务栏的)
5 个解决方案
#1
用while循环,遍历整个窗体
#2
遍历进程,判断进程是否有窗体~
#3
#4
FindWindow, FindChildWindow
GetWindowThreadProcessId获取窗口的进程ID
GetWindowThreadProcessId获取窗口的进程ID
#5
Win32 API - EnumWindows
#1
用while循环,遍历整个窗体
#2
遍历进程,判断进程是否有窗体~
#3
http://edu.codepub.com/2009/0812/13149.php
http://blog.csdn.net/iwteih/archive/2007/01/15/1483743.aspx
http://blog.csdn.net/iwteih/archive/2007/01/15/1483743.aspx
#4
FindWindow, FindChildWindow
GetWindowThreadProcessId获取窗口的进程ID
GetWindowThreadProcessId获取窗口的进程ID
#5
Win32 API - EnumWindows