Windows 7 Application Restart and Application Recovery Explained [Video]

In Windows Vista Microsoft introduced two closely related features: Application Restart and Application Recovery. These features are designed to eliminate much of the pain caused by the unexpected termination of your app, whether as a result of an unhandled exception, a "hard hang," or any other crash."Application Recovery" applies to apps that've a "document" or […]

In Windows Vista Microsoft introduced two closely related features: Application Restart and Application Recovery. These features are designed to eliminate much of the pain caused by the unexpected termination of your app, whether as a result of an unhandled exception, a "hard hang," or any other crash.

"Application Recovery" applies to apps that've a "document" or any other in-memory info that might be lost when the app closes unexpectedly. "Application Restart" applies to all app, whether they might have unsaved data or not, and to more unexpected closes, including a DLL update or a system reboot. Today, a large number of apps such as Windows Office (Microsoft Word and friends) use these features. Even if something does go wrong (and when it comes to software, it's most likely that at some point something will go wrong), the app together with the operating system can provide a seamless recovery path that makes the user feel a little less frustrated.

To register the app to restart and recovery in case it crashes again. Simply call the RegisterForRestartAndRecovery method by passing a string as the name of the app, the doc as the data object to save, and the file type to save.

The recipe takes care of everything for you. The temporary recovery files are saved in the Roaming Application Data folder usually located at "C:\Users\<your user name>\AppData\Roaming". The file names are guaranteed to be unique, the format is up to you, binary or XML. This way, we can make sure that a given application can handle multiple users and multiple crashes. Once recovered, the files are removed.

Here's a short video by Kate Gregory, explaining this in great detail:

And, this video showing the native APIs.

More Info: Windows Restart and Recovery Recipe

[Source]