/// <summary> /// Registers an application for automatic restart if the application is terminated by Windows Error Reporting. /// </summary> /// <param name="settings">An object that specifies the command line arguments used to restart the /// application, and the conditions under which the application should not be restarted.</param> /// <remarks>A registered application will not be restarted if it executed for less than 60 seconds before terminating.</remarks> private static void RegisterForApplicationRestart(RestartSettings settings) { if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) { HResult hr = AppRestartRecoveryNativeMethods.RegisterApplicationRestart(settings.Command, settings.Restrictions); switch (hr) { case HResult.Fail: throw new InvalidOperationException("Application failed to registered for restart."); case HResult.InvalidArgument: throw new ArgumentException("Failed to register application for restart due to bad parameters."); } } }
/// <summary> /// Registers an application for automatic restart if the application is terminated by Windows Error Reporting. /// </summary> /// <param name="settings">An object that specifies the command line arguments used to restart the /// application, and the conditions under which the application should not be restarted.</param> /// <remarks>A registered application will not be restarted if it executed for less than 60 seconds before terminating.</remarks> private static void RegisterForApplicationRestart(RestartSettings settings) { if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) { HResult hr = AppRestartRecoveryNativeMethods.RegisterApplicationRestart(settings.Command, settings.Restrictions); switch (hr) { case HResult.Fail: throw new InvalidOperationException("Application failed to registered for restart."); case HResult.InvalidArgument: throw new ArgumentException("Failed to register application for restart due to bad parameters."); } } }