Board index » delphi » getting exit codes?

getting exit codes?

Does anyone know the API call to get an exit code from a terminating
DOS or Win executable?  I'm using ShellExecute to launch the app and
GetModuleUsage to monitor its status.  But how do I check the return
value?

What I'm trying to do is get the status of the application's termination
so I can inform the user if it completed successfully or with an error.

rk

 

Re:getting exit codes?


In article <4e2vv7...@news.internetmci.com>, Rich Knapp
<rkn...@mcimail.com> writes
Quote
>Does anyone know the API call to get an exit code from a terminating
>DOS or Win executable?  I'm using ShellExecute to launch the app and
>GetModuleUsage to monitor its status.  But how do I check the return
>value?

>What I'm trying to do is get the status of the application's termination
>so I can inform the user if it completed successfully or with an error.

>rk

I don't believe it can be done.  It is possible using the 32-bit API as
there is a new GetExitCodeProcess function provided for this purpose.
--
Julian Moss                                      J M Technical Services
{*word*19}ermouth, Cumbria, UK                 Technical Writing and Software
(+44) 1900 826514                              jm...@jmtech.demon.co.uk

Re:getting exit codes?


Quote
Julian Moss <jm...@jmtech.demon.co.uk> wrote:
>In article <4e2vv7...@news.internetmci.com>, Rich Knapp
><rkn...@mcimail.com> writes
>>Does anyone know the API call to get an exit code from a terminating
>>DOS or Win executable?  I'm using ShellExecute to launch the app and
>>GetModuleUsage to monitor its status.  But how do I check the return
>>value?

>>What I'm trying to do is get the status of the application's termination
>>so I can inform the user if it completed successfully or with an error.

>>rk
>I don't believe it can be done.  It is possible using the 32-bit API as
>there is a new GetExitCodeProcess function provided for this purpose.
>--
>Julian Moss                                      J M Technical Services
>cockermouth, Cumbria, UK                 Technical Writing and Software
>(+44) 1900 826514                              jm...@jmtech.demon.co.uk

Well, if instead of GetModuleUsage, you set up a callback using the
NotifyRegister Win API, then when there is an NFY_EXITTASK
notification, the exit code is in the bottom byte of the dwData
parameter. But it hasn't been as simple as it sounds, for me,
puttering with it off & on. This callback apparently will not work
properly with the smart callback option on. I think I have gotten
around this without turning off smart callbacks or doing it in a DLL,
but I it's not yet what I would like. Where I'm heading is a
TExecNanny class whose instances watch over the execution of exec
children (what else ;-) and their life cycle milestones. So you can
start several at once, poll status property (milestone set), and/or
request a message for selected status change types. It's to be a unit
that works independently of smart callback option state, and is not a
DLL and doesn't use one. Exitcode will be a property, valid after
exit milestone.

I think I saw someone's post that they were doing something to
encapsulate NotifyRegister, but I never saw an ANNOUNCE for it,
and no one seems to pipe up suggesting it as a solution for the
numerous how-do-I-check-termination questions. Mine is now based
on WinExec. Perhaps I should change it to, or add, ShellExecute.

I'm not sure I see everything through my newsfeed though ;-/

Anyway, I seem to be getting the exit code, so I think it can
be done, at least some of the time.

Regards, Bengt Richter

Other Threads