1234567891011121314151617
BOOL TerminateWindow(__in HWND hWnd) { DWORD dwProcessId; HANDLE hProcess; BOOL bRet = FALSE; GetWindowThreadProcessId(hWnd, &dwProcessId); hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId); if(hProcess != NULL) { if(TerminateProcess(hProcess, 0)) bRet = TRUE; CloseHandle(hProcess); } return bRet; }