I have a part in my single dialog visual C++ program that does a shell execute.... ShellExecute(this->m_hWnd,"open", blah blah.
The problem is I have another one after that, but in between those I have some code, BUT it executes the first program, doesnt wait untill the first program is terminated, and does the code and opens the second program while the first is still open! How do I get it to execute a program and stop executing code untill that program terminates?
Check the flags for ShellExecute, I am sure there is a way to do that. You can also use system() which does block until done.
This is actually a windows programming problem, not C++ as such.
ShellExecute() does not wait for the program executed to complete. If you want to do that, look up CreateProcess(). The usage of that function is more complex(you have more control, and can get more information about the new process being executed). The last argument contains a handle to a process. If you wait on that handle using WaitForSingleObject() or a similar function, you can wait until the spawned program exits.