| 1850 | |
| 1851 | |
| 1852 | void Util_WinKill(HWND hWnd) |
| 1853 | { |
| 1854 | DWORD_PTR dwResult; |
| 1855 | // Use WM_CLOSE vs. SC_CLOSE in this case, since the target window is slightly more likely to |
| 1856 | // respond to that: |
| 1857 | if (!SendMessageTimeout(hWnd, WM_CLOSE, 0, 0, SMTO_ABORTIFHUNG, 500, &dwResult)) // Wait up to 500ms. |
| 1858 | { |
| 1859 | // Use more force - Mwuahaha |
| 1860 | DWORD pid = 0; |
| 1861 | GetWindowThreadProcessId(hWnd, &pid); |
| 1862 | HANDLE hProcess = pid ? OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid) : NULL; |
| 1863 | if (hProcess) |
| 1864 | { |
| 1865 | TerminateProcess(hProcess, 0); |
| 1866 | CloseHandle(hProcess); |
| 1867 | } |
| 1868 | } |
| 1869 | } |
| 1870 | |
| 1871 | |
| 1872 |
no outgoing calls
no test coverage detected