WinExec return value, Createprocess return value? VC++ 6.0
-
I have a dialog app with a function similar to this: void CMyDlg::OnButton1() { //This bit works WinExec("cmd.exe /c xcopy /s "+myfolder+" "+target_folder+" >>mylog.txt&exit",SW_HIDE); // This is what i want to do: // if (all files have been copied and cmd.exe exits then display the msgbox, if not, wait until filecopy is done and then display the msgbox) // { AfxMessageBox("Done! All files copied to target folder.",MB_OK|MB_ICONINFORMATION); // } } The way the function works right now, the msgbox displays too early, and not after all the files are copied. I guess i need some kind of return value, and then if its true/false then display msgbox. How to solve this problem, any suggestions? Is this "doable" in any easy way? Createprocess? If so, how would the Createprocess code look like? thx!
-
I have a dialog app with a function similar to this: void CMyDlg::OnButton1() { //This bit works WinExec("cmd.exe /c xcopy /s "+myfolder+" "+target_folder+" >>mylog.txt&exit",SW_HIDE); // This is what i want to do: // if (all files have been copied and cmd.exe exits then display the msgbox, if not, wait until filecopy is done and then display the msgbox) // { AfxMessageBox("Done! All files copied to target folder.",MB_OK|MB_ICONINFORMATION); // } } The way the function works right now, the msgbox displays too early, and not after all the files are copied. I guess i need some kind of return value, and then if its true/false then display msgbox. How to solve this problem, any suggestions? Is this "doable" in any easy way? Createprocess? If so, how would the Createprocess code look like? thx!
Google for "CProcessWait". It used to be in an article here on CP, but PJ Naughter or Arendt (sorry do not know anymore) put it in a utility library.
Don't follow any man spiritually, don't do anything that will get you in sh*t if god is real - Bradml[^]
-
I have a dialog app with a function similar to this: void CMyDlg::OnButton1() { //This bit works WinExec("cmd.exe /c xcopy /s "+myfolder+" "+target_folder+" >>mylog.txt&exit",SW_HIDE); // This is what i want to do: // if (all files have been copied and cmd.exe exits then display the msgbox, if not, wait until filecopy is done and then display the msgbox) // { AfxMessageBox("Done! All files copied to target folder.",MB_OK|MB_ICONINFORMATION); // } } The way the function works right now, the msgbox displays too early, and not after all the files are copied. I guess i need some kind of return value, and then if its true/false then display msgbox. How to solve this problem, any suggestions? Is this "doable" in any easy way? Createprocess? If so, how would the Createprocess code look like? thx!
rolfhorror wrote:
Createprocess? If so, how would the Createprocess code look like?
Call
CreateProcessEx()
followed byWaitForSingleObject()
.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne