1
2
3
4
5
6
7
8
9
10
11
12
DWORD nProcessID;
HANDLE hProcess = NULL;
::GetWindowThreadProcessId((HWND)handle,&nProcessID); // handle要关闭的进程句柄,可以使用FindWindow获取

hProcess = ::OpenProcess(PROCESS_TERMINATE,FALSE,nProcessID);

if (!::TerminateProcess(hProcess, 0))
{
DWORD derror = GetLastError();
return FALSE;
}
return TRUE;