| 52 | |
| 53 | |
| 54 | HWND GetProcessWindow(DWORD processId) { |
| 55 | HWND hWnd = FindWindowEx(nullptr, nullptr, nullptr, nullptr); |
| 56 | |
| 57 | while (hWnd != nullptr) { |
| 58 | if (GetParent(hWnd) == nullptr && GetWindowTextLength(hWnd) > 0 && IsWindowVisible(hWnd)) { |
| 59 | DWORD windowProcessId; |
| 60 | GetWindowThreadProcessId(hWnd, &windowProcessId); |
| 61 | |
| 62 | if (windowProcessId == processId) { |
| 63 | // Found a match. |
| 64 | break; |
| 65 | } |
| 66 | } |
| 67 | hWnd = GetWindow(hWnd, GW_HWNDNEXT); |
| 68 | } |
| 69 | return hWnd; |
| 70 | } |
| 71 | |
| 72 | void GetProcesses(std::vector<Process>& processes) { |
| 73 | static char fileName[_MAX_PATH]; |