How to kill a process?

How to use C++ to stop a running process on Windows?
You "just" obtain a handle (HPROCESS) to the process and call TerminateProcess() on it.

The catch it that you're got be able to obtain PROCESS_TERMINATE access right to handle, which usually means you have to be an administrator, and then you have to explicity grant yourself SeDebugPrivilege privilege.

Andy

PS Technically, you're not using C++ to stop the process; you're calling a WIN32 API function (which is C) using C++.
Last edited on
Topic archived. No new replies allowed.