コード例 #1
0
        private void uninstallBtn_Click(object sender, EventArgs e)
        {
            if (Utility.RequireAdministrator())
            {
                return;
            }

            switch (ScriptInstaller.Uninstall())
            {
            case 0:
                MessageBox.Show("BeautySearch successfully uninstalled", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            case ScriptInstaller.ERR_NOT_INSTALLED:
                MessageBox.Show("BeautySearch is not installed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case ScriptInstaller.ERR_READ:
                MessageBox.Show("Failed to read target file (not enough permissions?)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case ScriptInstaller.ERR_WRITE:
                MessageBox.Show("Failed to write target file (not enough permissions?)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case ScriptInstaller.ERR_KILL_FAILED:
                MessageBox.Show("BeautySearch has been uninstalled, sign out and sign in for the change to take effect", "BeautySearch", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }

            UpdateInstallStatus();
        }
コード例 #2
0
        private void installBtn_Click(object sender, EventArgs e)
        {
            if (Utility.RequireAdministrator())
            {
                return;
            }

            FeatureControl features = new FeatureControl();

            foreach (int i in featureBox.CheckedIndices)
            {
                features.Enable((featureBox.Items[i] as ListItem).Value);
            }


            switch (ScriptInstaller.Install(features))
            {
            case 0:
                MessageBox.Show("BeautySearch successfully installed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            case ScriptInstaller.ERR_READ:
                MessageBox.Show("Failed to read target file (not enough permissions?)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case ScriptInstaller.ERR_WRITE:
                MessageBox.Show("Failed to write target file (not enough permissions?)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case ScriptInstaller.ERR_KILL_FAILED:
                MessageBox.Show("Sign out and sign in to finish installation", "BeautySearch", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            case ScriptInstaller.ERR_OLD_BUILD:
                MessageBox.Show("BeautySearch can be installed only on Windows 10 May 2020 Update (20H1, Build 19041) and higher", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }

            UpdateInstallStatus();
        }
コード例 #3
0
 private void UpdateInstallStatus()
 {
     installBtn.Text = ScriptInstaller.IsInstalled() ? "Reinstall" : "Install";
 }