There are three applications main.exe (C++), one.exe (C++) and two.exe (.net).
I want to terminate one.exe and two.exe from main.exe if they are running.
There are three applications main.exe (C++), one.exe (C++) and two.exe (.net).
I want to terminate one.exe and two.exe from main.exe if they are running.
Normal GUI applications? Just send them WM_CLOSE
.
If you have Process ID for one.exe and two.exe you can get process handle and use TerminateProcess
function. Here is the code sample:
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (hProcess == NULL)
{
return;
}
UINT uExitCode;
BOOL result = TerminateProcess(hProcess, uExitCode);
CloseHandle(hProcess);
If it's a GUI application, you may send a WM_CLOSE message to the other application.
Or if you want to kill the other process, then use TerminateProcess() function.