Exemplo n.º 1
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (m_CustomKeyValidate == null)
            {
                return;
            }

            if (tbCustomSerialNo.Text.Length <= 0)
            {
                return;
            }

            if (m_CustomKeyValidate.IsValid == false)
            {
                return;
            }

            tbVerificationCode.Text = m_KeyGen.GenKey(Convert.ToInt32(numVerifyDaysLeft.Value), m_CustomKeyValidate.DecodedMachineCode);

            m_Verify = m_KeyGen.ValidateGenKey(tbVerificationCode.Text);

            if (m_Verify.IsValid == false)
            {
                lblVerifyIsValidValue.Text = "X";

                lblVerifyIsValidValue.Visible      = false;
                lblVerifyCreationDateValue.Visible = false;
                lblVerifyMachineCodeValue.Visible  = false;
                lblVerifyExpiredDateValue.Visible  = false;
            }
            else
            {
                lblVerifyIsValidValue.Text = "O";

                lblVerifyIsValidValue.Visible      = true;
                lblVerifyCreationDateValue.Visible = true;
                lblVerifyMachineCodeValue.Visible  = true;
                lblVerifyExpiredDateValue.Visible  = true;

                lblVerifyCreationDateValue.Text = m_Verify.CreationDate.ToString("yyyy/MM/dd hh:mm:ss");
                lblVerifyExpiredDateValue.Text  = m_Verify.ExpireDate.ToString("yyyy/MM/dd hh:mm:ss");
                lblVerifyMachineCodeValue.Text  = m_Verify.DecodedMachineCode.ToString();
            }
        }
Exemplo n.º 2
0
        private void BtnFixed_Click(object sender, EventArgs e)
        {
            //先產生一組序號;//
            string sn = m_KeyGen.GenKey(30);

            //取得此SN的機械碼;//
            m_CustomKeyValidate = m_KeyGen.ValidateGenKey(sn);
            string machineCode = m_CustomKeyValidate.DecodedMachineCode.ToString();

            //判斷是否為指定的電腦,不是的話不可使用此程式;//
            if (machineCode != tbGiveCPU.Text)
            {
                MessageBox.Show(this, "非指定電腦,不允許進行此操作!", "訊息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //進行序號修復;//
            m_KeyGen.SaveSN(tbGiveSN.Text);

            //更新本機電腦資訊;//
            tbCurrentSN.Text = m_KeyGen.GetKeyFromRegistry();
        }