Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Comunicados
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 Discussões

ShellExecuteEx and enquiring/terminating the resulting process

acar
Principiante
1.222 Visualizações
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 Solução
Steven_L_Intel1
Funcionário
1.222 Visualizações
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.

Ver solução na publicação original

4 Respostas
Steven_L_Intel1
Funcionário
1.222 Visualizações
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.
acar
Principiante
1.222 Visualizações
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.
Steven_L_Intel1
Funcionário
1.223 Visualizações
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.
acar
Principiante
1.222 Visualizações
That works a treat. Thanks Steve.
Responder