コード例 #1
0
        /// <summary>
        /// Removes an application's restart registration.
        /// </summary>
        /// <exception cref="Microsoft.WindowsAPICodePack.ApplicationServices.ApplicationRecoveryException">
        /// The attempt to unregister for restart failed.</exception>
        public static void UnregisterApplicationRestart()
        {
            CoreHelpers.ThrowIfNotVista();

            HResult hr = AppRestartRecoveryNativeMethods.UnregisterApplicationRestart();

            if (!CoreErrorHelper.Succeeded(hr))
            {
                throw new ApplicationRecoveryException(LocalizedMessages.ApplicationRecoveryFailedToUnregisterForRestart);
            }
        }
コード例 #2
0
        /// <summary>
        /// Removes an application's restart registration.
        /// </summary>
        /// <exception cref="System.ComponentModel.Win32Exception">
        /// The attempt to unregister for restart failed.</exception>
        public static void UnregisterApplicationRestart()
        {
            // Throw PlatformNotSupportedException if the user is not running Vista or beyond
            CoreHelpers.ThrowIfNotVista();

            HRESULT hr = AppRestartRecoveryNativeMethods.UnregisterApplicationRestart();

            if (hr == HRESULT.E_FAIL)
            {
                throw new ExternalException("Unregister for restart failed.");
            }
        }