MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / Util_WinKill

Function Util_WinKill

source/script_autoit.cpp:1852–1869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1850
1851
1852void 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

Callers 2

WinCloseFunction · 0.85
Util_ShutdownHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected