What’s the best way to end a c++ program launched with ShellExecute function from the main program?. like..
ShellExecute(hwnd, TEXT("open"), TEXT("c:\\tools\\123\\myProgram.exe"),
TEXT(""), NULL, 0);
In this case the launched program is “my Program.exe” and i want to end them. Both the main program & the launched program console application written in vc++.
In the sub-program:
You could tell it to do this from the main program through inter-process communication or by sending a control sequence of some kind to the sub-program’s
stdin. PostingWM_QUITorWM_CLOSEto the other process should also work if it has a message pump.TerminateProcess()will end the program, but it’s certainly not the best way. (cleanup isn’t run)Exit(0)isn’t a bad way to go either, but it also requires the sub-program to be told it should terminate.