[ACCEPTED]-Can I handle the killing of my windows process through the Task Manager?-process

Accepted answer
Score: 12

There are two ways to kill application in 4 Task Manager.

  • Killing through Applications tab would roughly be equivalent of SIGTERM. Application may intercept it and do more processing, since it's basically sending a "close window" message. Message to catch is WM_CLOSE.
  • Killing through Processes tab would roughly be equivalent of SIGKILL. There is nothing you can do to intercept that, short of monitoring user's actions in Task Manager's listbox and End Process button, or having a watchdog process that will see when the first one is killed.

Alternatively, design the application 3 in a way that does not require cleanup, or 2 in a way that it will perform cleanup at 1 startup.

Score: 1

I think you will need another PID that is 2 monitoring the PID of your app.exe and does 1 the necessary work at the time.

Score: 0

That depends, if the user chooses to "End 7 Task" your application you will be 6 notified and you can handle it see this.

but if the 5 user chooses to end the process, you have 4 no way to handle it in your application. the 3 easiest way would be a second process or 2 you can inject into process manager and 1 hook the TerminateProcess API.

More Related questions