Terminate a process
-
Hi, I want to terminate a process. I have porcessid and HWND. How to terminate using these? Regards, JM
The first rule of terminating a process is not to do it: prefer asking it to close down nicely. See http://support.microsoft.com/kb/178893[^]. That said, terminating a process is sometimes necessary as a last resort. The TerminateProcess[^] function will do the trick. It requires a process
HANDLE
but you only have a process id: use OpenProcess[^] to get aHANDLE
from it.Steve
-
The first rule of terminating a process is not to do it: prefer asking it to close down nicely. See http://support.microsoft.com/kb/178893[^]. That said, terminating a process is sometimes necessary as a last resort. The TerminateProcess[^] function will do the trick. It requires a process
HANDLE
but you only have a process id: use OpenProcess[^] to get aHANDLE
from it.Steve
Try this.... HANDLE prHandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, dwProcessID); if (NULL != prHandle) { TerminateProcess(prHandle, 0); }
-
Try this.... HANDLE prHandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, dwProcessID); if (NULL != prHandle) { TerminateProcess(prHandle, 0); }
If you know the hwnd of the window, then you can use SendMessage Function to close the window....
-
Try this.... HANDLE prHandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, dwProcessID); if (NULL != prHandle) { TerminateProcess(prHandle, 0); }
I'm not the one asking the question. Your suggestion is the procedure I outlined in my post.
Steve
-
I'm not the one asking the question. Your suggestion is the procedure I outlined in my post.
Steve
You are right Stephen, We two are in same direction. I just followed your reply thread. Not opened another thread, that's all. anyway sorry for the confusion.
-
Hi, I want to terminate a process. I have porcessid and HWND. How to terminate using these? Regards, JM