比如腾讯QQ这类程序是一个进程,多个窗口的。当你打开多个聊天窗口后,只有QQ.exe 一个进程在运行。当在任务栏上会出现多个聊天窗口。请问如何通过 C# 得到任务栏的窗口总数和窗口标题?这样我能进一步地判断,QQ大致上共打开了几个聊天窗口,甚至能知道聊天窗口的窗口标题。我知道有个API是 EnumDesktopWindows 可以实现类似的功能。不知道是否有更方便的,针对任务栏的方法,谢谢大家不吝赐教.
调试欢乐多
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetForegroundWindow();类似地调用windows api就可以了
Process[] process = Process.GetProcesses();
foreach(Process p in process)
{
Console.WriteLine(p.MainWindowTitle.ToString());
}
Console.ReadLine();