Dear All, I want to open another exe file in my C++ program. Let the exe file be A.exe. So I used shell execute inside my C++ program to open the file but as A.exe writes in a file certain data that I will use in the next step of my program I must wait till A.exe finishes. The execution time of A.exe can't be predicted, it may take a flash or it may take days!!, but I must wait till it finishes its code and output the file that I want to read. So is there a fucntion that I can call to wait till A.exe that I openned with shell execute finishes?. Please explain clearly as I'm not a proffesional C++ programmer. Note: A.exe don't set a file openning restrictions, so I can open the file even it contains only part of the data not all of it. Thanks in advance.
WaelTheNoble
0
Newbie Poster
Recommended Answers
Jump to PostAssuming Windows, here's an example of waiting for an exe to finish.
STARTUPINFO si = {sizeof (STARTUPINFO)}; PROCESS_INFORMATION pi; CreateProcess( "\\windows\\notepad.exe", NULL, 0, 0, 0, 0, 0, 0, &si, &pi ); WaitForSingleObject( pi.hProcess, INFINITE );
Jump to PostIt seems fairly self-explanatory. Remember to (of course) look the functions up on MSDN. Just include windows.h to use the code above.
If you must use ShellExecute (and there certainly can be …
All 5 Replies
nucleon
114
Posting Pro in Training
WaelTheNoble
0
Newbie Poster
WaelTheNoble
0
Newbie Poster
nucleon
114
Posting Pro in Training
WaelTheNoble
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.