public static IEnumerable <IntPtr> WindowHandles(this Process process) { var handles = new List <IntPtr>(); foreach (ProcessThread thread in process.Threads) { Win32Helpers.EnumThreadWindows((uint)thread.Id, (hWnd, lParam) => { handles.Add(hWnd); return(true); }, IntPtr.Zero); } return(handles); }
public static IEnumerable <IntPtr> GetAllWindows(this Process p) { var handles = new List <IntPtr>(); System.Threading.Thread.Sleep(100); foreach (ProcessThread thread in p.Threads) { Win32Helpers.EnumThreadWindows((uint)thread.Id, (hWnd, lParam) => { handles.Add(hWnd); return(true); }, IntPtr.Zero); } return(handles); }