Am using VC++ compiler i want to know how to kill a process. is there any functions.
i tried with TerminateProcess(); but i couldn't do...
Am using VC++ compiler i want to know how to kill a process. is there any functions.
i tried with TerminateProcess(); but i couldn't do...
TerminateProcess
requires the PROCESS_TERMINATE
right. If you're getting the process handle from OpenProcess
, then the dwDesiredAccess parameter must at least include PROCESS_TERMINATE
.
If you're trying to kill an elevated process, then your app (the app doing the killing) must also be elevated.
What error code are you getting from GetLastError()
?
I don't know exactly what you want to do but you have to know TerminateProcess()
just kills the process without giving him a chance to close properly.
You might want first to send a WM_CLOSE
message to the application and then, if it doesn't respond, kill it with TerminateProcess()
.
Dr Dobbs has a great article (with samples) just here.
You might want to take a look.
Just to make sure you did it right:
OpenProcess
to get the process handle from a process ID (requesting PROCESS_TERMINATE
access rights)TerminateProcess
on this handleWhat exactly went wrong with this approach?