private async void InstallDsOnClick()

in ScpDriverInstaller/MainWindow.xaml.cs [251:322]


        private async void InstallDsOnClick(object sender, RoutedEventArgs routedEventArgs)
        {
            MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy;

            var rebootRequired = false;
            var failed = false;
            uint result = 0;
            var ds3InfPath = Path.Combine(GlobalConfiguration.AppDirectory, "WinUSB", "Ds3Controller.inf");
            var ds4InfPath = Path.Combine(GlobalConfiguration.AppDirectory, "WinUSB", "Ds4Controller.inf");

            MainBusyIndicator.SetContentThreadSafe(Properties.Resources.DualShockSetupInstalling3);

            await Task.Run(() => result = Difx.Instance.Install(ds3InfPath,
                DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT | DifxFlags.DRIVER_PACKAGE_FORCE, out rebootRequired));

            // ERROR_NO_SUCH_DEVINST = 0xE000020B
            if (result != 0 && result != 0xE000020B)
            {
                failed = true;

                ExtendedMessageBox.Show(this,
                    Properties.Resources.SetupFailedTitle,
                    Properties.Resources.SetupFailedInstructions,
                    Properties.Resources.SetupFailedContent,
                    string.Format(Properties.Resources.SetupFailedVerbose,
                        new Win32Exception(Marshal.GetLastWin32Error()), Marshal.GetLastWin32Error()),
                    Properties.Resources.SetupFailedFooter,
                    TaskDialogIcon.Error);
            }

            MainBusyIndicator.SetContentThreadSafe(Properties.Resources.DualShockSetupInstalling4);

            await Task.Run(() => result = Difx.Instance.Install(ds4InfPath,
                DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT | DifxFlags.DRIVER_PACKAGE_FORCE, out rebootRequired));

            // ERROR_NO_SUCH_DEVINST = 0xE000020B
            if (result != 0 && result != 0xE000020B)
            {
                failed = true;

                ExtendedMessageBox.Show(this,
                    Properties.Resources.SetupFailedTitle,
                    Properties.Resources.SetupFailedInstructions,
                    Properties.Resources.SetupFailedContent,
                    string.Format(Properties.Resources.SetupFailedVerbose,
                        new Win32Exception(Marshal.GetLastWin32Error()), Marshal.GetLastWin32Error()),
                    Properties.Resources.SetupFailedFooter,
                    TaskDialogIcon.Error);
            }

            MainBusyIndicator.IsBusy = !MainBusyIndicator.IsBusy;

            if (!failed)
            {
                ExtendedMessageBox.Show(this,
                    Properties.Resources.SetupSuccessTitle,
                    Properties.Resources.DualShockSetupSuccessInstruction,
                    Properties.Resources.SetupSuccessContent,
                    string.Empty,
                    string.Empty,
                    TaskDialogIcon.Information);
            }

            if (rebootRequired)
            {
                MessageBox.Show(this,
                    Properties.Resources.RebootRequiredContent,
                    Properties.Resources.RebootRequiredTitle,
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }
        }