示例#1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            string installPath = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\" + installedPathRegKeyName, "InstallPath", "") ?? "";

            state = InstallerState.Read(installPath);
            state.Update();
            if (e.Args.Length > 0 && e.Args[0] == "/uninstall")
            {
                if (MessageBox.Show("Are you sure you want to uninstall KinectToVR?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    if (Uninstaller.UninstallK2EX(installPath))
                    {
                        MessageBox.Show("Uninstalled successfully!");
                        if (Directory.Exists(installPath))
                        {
                            // https://stackoverflow.com/a/1305478/
                            ProcessStartInfo Info = new ProcessStartInfo();
                            Info.Arguments      = "/C choice /C Y /N /D Y /T 3 & rmdir /S /Q \"" + installPath + "\"";
                            Info.WindowStyle    = ProcessWindowStyle.Hidden;
                            Info.CreateNoWindow = true;
                            Info.FileName       = "cmd.exe";
                            Process.Start(Info);
                        }
                    }
                }
                Current.Shutdown(0);
            }
        }
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            string installPath = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\" + installedPathRegKeyName, "InstallPath", "") ?? "";

            // get system display language
            string displayLanguage = CultureInfo.InstalledUICulture.TwoLetterISOLanguageName;

            // import strings.json from resources and parse it into a JObject


            state = InstallerState.Read(installPath);
            state.Update();
            if (e.Args.Length > 0 && e.Args[0] == "/uninstall")
            {
                if (MessageBox.Show("Are you sure you want to uninstall KinectToVR?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    try {
                        if (Uninstaller.UninstallK2EX(installPath))
                        {
                            MessageBox.Show("Uninstalled successfully!");
                            if (Directory.Exists(installPath))
                            {
                                // https://stackoverflow.com/a/1305478/
                                ProcessStartInfo Info = new ProcessStartInfo();
                                Info.Arguments      = "/C choice /C Y /N /D Y /T 3 & rmdir /S /Q \"" + installPath + "\"";
                                Info.WindowStyle    = ProcessWindowStyle.Hidden;
                                Info.CreateNoWindow = true;
                                Info.FileName       = "cmd.exe";
                                Process.Start(Info);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("An error happened while trying to uninstall. Join our Discord for help on manually uninstalling.");
                        new ExceptionDialog(ex).ShowDialog();
                    }
                }
                Current.Shutdown(0);
            }
        }