Deallocate resources on process termination
问题 How I can deallocate resources when the process gets killed by, for example, the Task Manager? Is there a way to call a function before the process gets closed? 回答1: There really is nothing you can do if your process is killed. By definition, killing a process is just that - killing it. The process does not get an opportunity to run any code. This is very much "by design". Imagine that you could register a routine that was called when your process was killed by the user (or by another process