/// <summary> /// Gets all windows associated with a process. /// </summary> /// <param name="process"> The process. </param> /// <returns> /// The array with all window handles to all the windows of the specified process. /// An empty array is returned if the process does not have any windows. /// </returns> /// <exception cref="ArgumentNullException"> <paramref name="process" /> is null. </exception> public static IntPtr[] GetWindows(Process process) { if (process == null) { throw new ArgumentNullException(nameof(process)); } IntPtr[] allWindows = WindowsWindow.FindTopWindows(); IntPtr[] foundWindows = (from w in allWindows where WindowsWindow.GetProcess(w) .Id == process.Id select w).ToArray(); return(foundWindows); }