Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
OK, The subject line says it all. I need to start a windows GUI program when my user clicks a button and wait for the GUI to return. I've been mucking around with ::system and I can get the GUI running but the ::system function returns immediately...

Any Help?

Ron H.
Posted

1 solution

Good question, Ron! Try to do something like this:

C++
STARTUPINFO info={sizeof(info)};
PROCESS_INFORMATION processInfo;
if (CreateProcess(path, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo))
{
    ::WaitForSingleObject(processInfo.hProcess, INFINITE);
    CloseHandle(processInfo.hProcess);
    CloseHandle(processInfo.hThread);
}


Good luck!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900