Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

ShellExecuteEx and enquiring/terminating the resulting process

acar
Beginner
1,221 Views
I am using ShellExecuteEx to invoke hh.exe with an appropriate mapid. When my help file does not contain a topic with the sent mapid hh.exe exits. I would like to be able to pick this up in the calling application possibly by checking whether the process is still running or not. I have set %fmask=See_Mask_NoCloseProcess and get a %hprocess number returned. I note from looking at the Task Manager that this number is not the PID of the process so first question is how does hprocess relate to PID. Second question is how to check whether or not hprocess has terminated?
0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,221 Views
Assuming that hh.exe exits with some non-zero status if the mapid is invalid, I'd suggest using GetExitCodeProcess. You could do this in a loop with a sleep of 100ms or so, calling repeatedly until it no longer returns STILL_ACTIVE (259). Make sure you close the handle when you are done with it.

View solution in original post

0 Kudos
4 Replies
Steven_L_Intel1
Employee
1,221 Views
hprocess is a handle, which is, in reality, the address of an OS data structure referring to the process. You use WaitForSingleObject to wait for the process to terminate.
0 Kudos
acar
Beginner
1,221 Views
I wonder if you could give a little more information Steve. What I think I want is to be able to specify a routine to be called when the process started by ShellExecuteEx terminates and then to take some action if it terminated itself as a result of an invalid mapid. I don't see how WaitForSingleObject helps in this respect.
0 Kudos
Steven_L_Intel1
Employee
1,222 Views
Assuming that hh.exe exits with some non-zero status if the mapid is invalid, I'd suggest using GetExitCodeProcess. You could do this in a loop with a sleep of 100ms or so, calling repeatedly until it no longer returns STILL_ACTIVE (259). Make sure you close the handle when you are done with it.
0 Kudos
acar
Beginner
1,221 Views
That works a treat. Thanks Steve.
0 Kudos
Reply