riclueje
asked on
Kill a process with the pid.
I know the pid of a process that I want to kill. How I can do it on Windows NT? I haven´t found the kill function or its equivalent.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Right... You do it this way:
HANDLE aHandle = OpenProcess(PROCESS_TERMIN ATE, FALSE, proc-id);
int aStatus = TerminateProcess(aHandle, desired-exit-code);
if (!aStatus) {
char s[80];
sprintf(s, "TerminateProcess() failed, code: %d", aStatus);
AfxMessageBox(s);
}
CloseHandle(aHandle);
Sorry about the typo before... CloseHandle() should be used to
free the handle, not CloseProcess()...
HANDLE aHandle = OpenProcess(PROCESS_TERMIN
int aStatus = TerminateProcess(aHandle, desired-exit-code);
if (!aStatus) {
char s[80];
sprintf(s, "TerminateProcess() failed, code: %d", aStatus);
AfxMessageBox(s);
}
CloseHandle(aHandle);
Sorry about the typo before... CloseHandle() should be used to
free the handle, not CloseProcess()...
ASKER