Reputation: 1965
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 ?
Upvotes: 2
Views: 5800
Reputation: 56113
Try ShellExecuteEx
instead, which can return a HANDLE hProcess
of the newly-started process.
When/if you have a HANDLE hProcess
then I expect you can pass it as a parameter it to the TerminateProcess
function: which you would call (to terminate the child process) before your application stops.
Upvotes: 3