/// <summary> /// Custom, returns list of all windows with given title, /// utilizing FindWindowEx and GetClassName. /// </summary> /// <returns></returns> public static List<FoundWindow> FindAllWindows(string windowName) { var result = new List<FoundWindow>(); var hWnd = IntPtr.Zero; do { if ((hWnd = FindWindowEx(IntPtr.Zero, hWnd, null, windowName)) != IntPtr.Zero) { var window = new FoundWindow { HWnd = hWnd, WindowName = windowName }; var className = new StringBuilder(255); GetClassName(hWnd, className, className.Capacity); window.ClassName = className.ToString(); result.Add(window); } } while (hWnd != IntPtr.Zero); return result; }
/// <summary> /// Custom, returns list of all windows with given title, /// utilizing FindWindowEx and GetClassName. /// </summary> /// <returns></returns> public static List <FoundWindow> FindAllWindows(string windowName) { var result = new List <FoundWindow>(); var hWnd = IntPtr.Zero; do { if ((hWnd = FindWindowEx(IntPtr.Zero, hWnd, null, windowName)) != IntPtr.Zero) { var window = new FoundWindow { HWnd = hWnd, WindowName = windowName }; var className = new StringBuilder(255); GetClassName(hWnd, className, className.Capacity); window.ClassName = className.ToString(); result.Add(window); } }while (hWnd != IntPtr.Zero); return(result); }