views:

196

answers:

1

hello,

how in an console application detect that the user click on the "End" process in the task scheduler ?

i try to setup SetConsoleCtrlHandler, but unfortunatly it's seam to not work (but curiously it's work in the task manager)

i also try to catch the wm_quit or wm_close without any success ...

thanks for you help !

+1  A: 

End process, not "end application"?

I believe you can't. End process does TerminateProcess, which cannot be handled.

This is an analog of POSIX SIGKILL.

EFraim
but we must can!? for exemple in the task scheduler their is an option "If the running task does not end when requested, force it to stop" ... so what the purpose of this option if we have no way in the application to catch the "End" ! i believe that when the user click on the "End" it's something soft and if the process not terminate himself then it's something hard like terminateprocess
loki
@loki: If you do End Task, in XP that's one thing. (message) End process is another.
EFraim
thanks EFraim, i m in vista, but i m not speaking about the task manager (where we have "end process" that do terminateprocess) but about the task scheduler (where we have only "End")
loki
@loki: I do not run Vista, but I *guess* the task scheduler is based on Job object API there, and the option specifies whether to call TerminateJobObject or not.
EFraim
thanks EFraim, i look as far as possible and unfortunatly their is no option :(
loki