Published
Wednesday, December 20, 2006 6:10 AM
by
martin
Windows Vista introduced new APIs to allow applications to register themselves for automatic restart, if they fail in some way. In addition, you can ask the OS to invoke a specific callback inside the application, just before the process is killed. This might allow you to save off any important state so that it can be restored when the app is restarted.
For a good discussion of the mechanics, see Daniel's post here.
If you like listening to Mike Taulty's voice, see his nugget here (or download it here).
I've built a sample (C# and Windows Forms) that uses these new APIs. The subtlety is that, when the app crashes, the form object is destroyed. The sample illustrates how to keep your data somewhere safe so that the recovery callback is able to save it to a file.