Board index » delphi » Detecting end of program - by killing process ?

Detecting end of program - by killing process ?

Hi,

I have an app that if killed by terminating the process, does not seem to be
notified in a way that I can detect to clean up (ie. no onclose, formdestroy
etc), in essence no message seems to be sent to pick up.

Any ideas on how to trap this case of program closure ?

Regards

nick

 

Re:Detecting end of program - by killing process ?


You could trap the WM_ENDSESSION message.

ps. Does the fact that you terminated the program have something to do with
the fact that your program was in a very CPU intensive procedure ? In that
case you should add some Application.ProcessMessages to this procedure !

"Nick Farrow" <Nick.Far...@bt.com> schreef in bericht
news:95trbm$pmb$1@pheidippides.axion.bt.co.uk...

Quote
> Hi,

> I have an app that if killed by terminating the process, does not seem to
be
> notified in a way that I can detect to clean up (ie. no onclose,
formdestroy
> etc), in essence no message seems to be sent to pick up.

> Any ideas on how to trap this case of program closure ?

> Regards

> nick

Re:Detecting end of program - by killing process ?


In article <95trbm$pm...@pheidippides.axion.bt.co.uk>, Nick.Far...@bt.com
says...

Quote
> Hi,

> I have an app that if killed by terminating the process, does not seem to be
> notified in a way that I can detect to clean up (ie. no onclose, formdestroy
> etc), in essence no message seems to be sent to pick up.

Killed is killed. You don't get notification. If you're writing a
"terminator" program, it's always best to locate the other program's main
window and politely send it a WM_CLOSE - if that works, it's much
cleaner. Under WinNT-family, you can "inject" an ExitProcess call into
the process (described in Windows Developer's Journal August 1999). If
you must just "kill" the process, you can expect problems. And if you're
the process being "killed", there's basically nothing you can do.
--
Neil J. Rubenking
Contributing Technical Editor
PC Magazine

Re:Detecting end of program - by killing process ?


Thanks for that,

I was trying to clean up if someone else killed my app from the process list
in task manager.

"Neil J. Rubenking" <jrube...@SPAM-B-GONE.mother.com> wrote in message
news:MPG.14ec4814412a9c1e98999d@news.mother.com...

Quote
> In article <95trbm$pm...@pheidippides.axion.bt.co.uk>, Nick.Far...@bt.com
> says...
> > Hi,

> > I have an app that if killed by terminating the process, does not seem
to be
> > notified in a way that I can detect to clean up (ie. no onclose,
formdestroy
> > etc), in essence no message seems to be sent to pick up.

> Killed is killed. You don't get notification. If you're writing a
> "terminator" program, it's always best to locate the other program's main
> window and politely send it a WM_CLOSE - if that works, it's much
> cleaner. Under WinNT-family, you can "inject" an ExitProcess call into
> the process (described in Windows Developer's Journal August 1999). If
> you must just "kill" the process, you can expect problems. And if you're
> the process being "killed", there's basically nothing you can do.
> --
> Neil J. Rubenking
> Contributing Technical Editor
> PC Magazine

Re:Detecting end of program - by killing process ?


Asker, Norway
bjorgeremovet...@itte.no (remove the obvious)

"Nick Farrow" <Nick.Far...@bt.com> skrev i melding
news:960nnv$isr$1@pheidippides.axion.bt.co.uk...

Quote
> Thanks for that,

> I was trying to clean up if someone else killed my app from the process
list
> in task manager.

I believe the Task Manager attempts a normal shutdown, but gets more
"insensitive" if the process will not end.

--
Bjoerge Saether
Consultant / Developer
http://www.itte.no

Other Threads