Ejemplo n.º 1
0
        private void BackupKey_Click(object sender, EventArgs e)
        {
            string productKey = LicensingHelper.GetProductKey();

            if (productKey == null)
            {
                MessageBox.Show(
                    "No Product key is currently installed. No backup is necessary.",
                    "No Product key installed"
                    );
                return;
            }

            SaveFileDialog dialog = new SaveFileDialog();

            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            dialog.RestoreDirectory = true;
            dialog.Title            = "Backup current Product key";
            dialog.FileName         = "product-key.txt";
            dialog.CheckPathExists  = true;
            dialog.OverwritePrompt  = true;
            dialog.Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                File.WriteAllText(
                    dialog.FileName,
                    "Product key backup file created by jaw - " +
                    DateTime.Now.ToString(CultureInfo.CurrentCulture) + Environment.NewLine +
                    productKey + Environment.NewLine,
                    Encoding.UTF8
                    );
            }
        }
Ejemplo n.º 2
0
        // gets Windows edition and current product key, updates GUI with available actions
        private async Task <bool> Step1Update()
        {
            // windows edition
            string s = await Task.Run(
                () => {
                return(LicensingHelper.GetWindowsSKU());
            });

            // current product key
            string oldkey = await Task.Run(
                () => {
                return(LicensingHelper.GetProductKey());
            });

            step1output.Text = s;

            // update gui
            if (s != null)
            {
                string key = SkuToProductKey.Get(s);
                if ((key != null && !key.Equals(oldkey)) || key == null)
                {
                    step1action.Text     = "Action: backup current key and install VL key.";
                    previousStepEnabled |= step1.Enabled = true;
                }
                else
                {
                    step1action.Text = "No action necessary: VL key is installed.";
                    step1.Enabled    = false;
                }
            }

            return(true);
        }