In MFC, I am using this code
ShellExecute(NULL, _T("open"), _T(EXTERNAL_APP), params,
_T(EXTERNAL_PATH), SW_HIDE);
to start an external program which runs in the background.
However when my app is terminated , this program is still running, as can be verified by inspecting the Windows Task Manager pane.
So my question is, how can I make the external program stop when my app stops ?
Try
ShellExecuteExinstead, which can return aHANDLE hProcessof the newly-started process.When/if you have a
HANDLE hProcessthen I expect you can pass it as a parameter it to theTerminateProcessfunction: which you would call (to terminate the child process) before your application stops.