You can kill the process using OpenProcess() and TerminateProcess(). The code will look something like this :
HANDLE handle = OpenProcess(PROCESS_TERMINATE, FALSE, ProcessID);
if (NULL != handle) {
TerminateProcess(handle, 0);
CloseHandle(handle);
}
For the inconvenience of the use of system("taskkill /pid xxxx")
, I invite you to read this post. A large number of answers have been given to explain why not to use this expression.
Slow: It has to jump through lots of unnecessary Windows code and a separate program for a simple operation.
Not portable: Dependent on the pause program.
Not good style: Making a System call should only be done when really necessary