Answer 3
I fear that this might not be possible. If your application is killed from outside, there is not much you can do.
Maybe you want to build up a GUI application instead. Then it is still posisble for the user to kill the application (e.g. through task manager and then killing the process), but there is no easy "X" button to click.
A possible trick could be to disable the close button (e.g. you search for the console window your application is running in and then try to modify this window directly. But you have to take care of special cases:
a) it is possible, that no window is there.
b) it is possible thta multiple windows are there because the tool was started multiple times.
At the moment I have no idea how to change an existing window so that the close button is no longer enabled. And I have to confess that I don't really like this dirty hack. But maybe this codeproject article shows a little, how you could find a window:
http://www.codeproject.com/KB/dialog/CWindow.aspx
With kind regards,
Konrad