Posted by: Christian Wimmer in: JEDI Windows API Headers
The people from Microsoft decided that the user has to be in full control over the computer. So there is no assured way to make a program user resistant. She can always use TerminateProcess to forcibly kill the process.
function KillProcess(const ProcessID : DWord): Boolean;
hProcess := OpenProcess(PROCESS_TERMINATE, False, ProcessID);
Result := TerminateProcess(hProcess, 0);
Because nobody reads the remarks section of TerminateProcess, I cite it here.
The TerminateProcess function is used to unconditionally cause a process to exit. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.
TerminateProcess initiates termination and returns immediately. This stops execution of all threads within the process and requests cancellation of all pending I/O. The terminated process cannot exit until all pending I/O has been completed or canceled.
And remind this little sentence.
A process cannot prevent itself from being terminated.
However there are some reasons not to make your application undestroyable.
Tell me how you liked this blog entry by adding a comment.