コード例 #1
0
        private void activateBtn_Click(object sender, EventArgs e)
        {
            int status;

            if (this.activateBtn.Text == "Deactivate")
            {
                status = LexActivator.DeactivateLicense();
                if (status == LexActivator.StatusCodes.LA_OK)
                {
                    this.statusLabel.Text         = "License deactivated successfully";
                    this.activateBtn.Text         = "Activate";
                    this.activateTrialBtn.Enabled = true;
                    return;
                }
                this.statusLabel.Text = "Error deactivating license: " + status.ToString();
                return;
            }
            status = LexActivator.SetLicenseKey(productKeyBox.Text);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                this.statusLabel.Text = "Error setting license key: " + status.ToString();
                return;
            }
            status = LexActivator.SetActivationMetadata("key1", "value1");
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                this.statusLabel.Text = "Error setting activation metadata: " + status.ToString();
                return;
            }
            status = LexActivator.ActivateLicense();
            if (status == LexActivator.StatusCodes.LA_OK || status == LexActivator.StatusCodes.LA_EXPIRED || status == LexActivator.StatusCodes.LA_SUSPENDED)
            {
                this.statusLabel.Text         = "Activation Successful :" + status.ToString();
                this.activateBtn.Text         = "Deactivate";
                this.activateTrialBtn.Enabled = false;
            }
            else
            {
                this.statusLabel.Text = "Error activating the license: " + status.ToString();
                return;
            }
        }