In general this is not possible , especially for a code in your application. The application itself has no control over this.
The most that is possible is not giving the process ( TERMINATE
) the privilege to shut down when you install the program. But this does not totally solve. Thankfully no software can do this.
The user can prevent the software from running automatically on the next startup and it will definitely kill your program. So it's not even worth the effort.
If he knows what he's doing, it's possible to give the privilege on his own without having to give a boot on the machine. There are specialized software that kill processes that can not be killed. Microsoft's Process Explorer can help you do this.
Certainly there are some possible devices like capturing NtTerminateProcess
in kernel or creating another program that is monitoring this principal. But no trick is effective . Worse, you think you're protected when you're not.
Forget this idea.