ShellExecute problem

This is a discussion on ShellExecute problem within the C++ Programming forums, part of the General Programming Boards category; I have a part in my single dialog visual C++ program that does a shell execute.... ShellExecute(this->m_hWnd,"open", blah blah.
The ...

ShellExecute problem

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?

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.