c++ - How to make the program waits till the command is executed -


i'm trying execute system command throught program wait till process terminated carry on executing code's instructions. i've been using sleep() didn't work out because relative mean execution time differs machine ...so there solution this?

consider code below(language==c++):

shellexecute(0, "open", "cmd.exe","/c rasdial adsl user pwd", 0, sw_hide); //can use system(). sleep(sec); if(checkconnection()) {cout <<"u r connected"; } 

wait till system command executed check connection (i think now).

use shellexecuteex instead of shellexecute, , call waitforsingleobject hprocess receive:

shellexecuteinfo info = { sizeof(shellexecuteinfo) }; // fill in values in shellexecuteinfo necessary if (shellexecuteex(&info)) {     waitforsingleobject (info.hprocess, infinity);     // new process has completed } else {     // launch failed } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -