コード例 #1
0
        private void buttonCompact_Click(object sender, RoutedEventArgs e)
        {
            if (
                MessageBox.Show(Application.Current.MainWindow, "Are you sure you want to compact your registry?",
                                Utils.ProductName, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }

            Wizard.IsBusy = true;

            var secureDesktop = new SecureDesktop();

            secureDesktop.Show();

            var compactWnd = new Compact();

            compactWnd.ShowDialog();

            secureDesktop.Close();

            Wizard.IsBusy = false;

            if (
                MessageBox.Show(Application.Current.MainWindow,
                                "You must restart your computer before the new setting will take effect. Do you want to restart your computer now?",
                                Utils.ProductName, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                // Restart computer
                Misc.PInvoke.ExitWindowsEx(Misc.PInvoke.ShutdownFlags.Reboot, Misc.PInvoke.ShutdownReasons.MajorOperatingsystem | Misc.PInvoke.ShutdownReasons.MinorReconfig | Misc.PInvoke.ShutdownReasons.FlagsPlanned);
            }

            _scanBase.MoveFirst();
        }
コード例 #2
0
        private void buttonCompact_Click(object sender, RoutedEventArgs e)
        {
            if (
                MessageBox.Show(Application.Current.MainWindow, "Are you sure you want to compact your registry?",
                                Utils.ProductName, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }

            Wizard.IsBusy = true;

            var secureDesktop = new SecureDesktop();

            secureDesktop.Show();

            var compactWnd = new Compact();

            compactWnd.ShowDialog();

            secureDesktop.Close();

            // Set errors fixed to number of registry hives
            Settings.Default.lastScanErrorsFixed = Wizard.RegistryHives.Count;
            Settings.Default.totalErrorsFixed   += Settings.Default.lastScanErrorsFixed;

            Wizard.IsBusy = false;

            if (
                MessageBox.Show(Application.Current.MainWindow,
                                "You must restart your computer before the new setting will take effect. Do you want to restart your computer now?",
                                Utils.ProductName, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                // Restart computer
                PInvoke.ExitWindowsEx(0x02, PInvoke.MajorOperatingSystem | PInvoke.MinorReconfig | PInvoke.FlagPlanned);
            }

            _scanBase.MoveFirst();
        }