Try TerminateProcess() as it will allow you to kill another process ans opposed to ExitProcess() whick kills the current process...
...Excuse my rushed example, but this should do what you want
Code:
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInfo;
string str = "Notepad.exe",
strEnt;
ZeroMemory( &StartupInfo, sizeof(STARTUPINFO));
StartupInfo.cb = sizeof(STARTUPINFO);
if(CreateProcess(NULL,
const_cast<CHAR*>(str.c_str()),
NULL,
NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&StartupInfo,
&ProcessInfo)){
cout << "Type \"QUIT\" to kill notepad" << endl;
cin >> strEnt;
if (strEnt == "QUIT"){
TerminateProcess(ProcessInfo.hProcess,
0);
}
}
return 0;
}
Oh...and beware...there may be Access right complications on WinNT and above. The Process handle needs PROCESS_TERMINATE rights. And as I am using toy windows (win98) as I sit here, I cant provide for that in my example