public static IReadOnlyList<IntPtr> GetWindowsHandles(this Process process) {
var handles = new List<IntPtr>();
foreach (ProcessThread thread in Process.GetProcessById(process.Id).Threads) {
User32.EnumThreadWindows(thread.Id, (hWnd, lParam) => { handles.Add(hWnd); return true; }, IntPtr.Zero);
}
return handles;
}
}