void killProcessByPid(DWORD pid)
{
// Folyamat lelõvése
HANDLE hProcess;
hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pid );
TerminateProcess(hProcess, 0);
CloseHandle( hProcess );
}
void killProcessByName(const char *procName) {
HANDLE hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof (pe32);
BOOL hRes = Process32First(hThreadSnap, &pe32);
while (hRes) {
if (strcmp(pe32.szExeFile, procName) == 0) {
HANDLE hProcess =
OpenProcess(PROCESS_TERMINATE, 0,
(DWORD) pe32.th32ProcessID);
if (hProcess != NULL) {
TerminateProcess(hProcess, 9);
CloseHandle(hProcess);
}
}
hRes = Process32Next(hThreadSnap, &pe32);
}
CloseHandle(hThreadSnap);
}