Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Instantiate the dialog box
            ActivateDialog dlg = new ActivateDialog();

            // Configure the dialog box
            dlg.Owner      = this;
            dlg.CodeFound += new CodeFoundEventHandler(dlg_CodeFound);

            // Open the dialog box modally
            dlg.ShowDialog();
        }
Пример #2
0
        void dlg_CodeFound(object sender, EventArgs e)
        {
            //Console.WriteLine("==============================");
            // Get the find dialog box that raised the event
            ActivateDialog dlg = (ActivateDialog)sender;

            // Get find results and select found text
            string           code = dlg.ActivateCode;
            string           sn;
            ActivationStatus status = VMProtect.SDK.ActivateLicense(code, out sn);

            //Console.WriteLine("==============================" + status);
            if (status == ActivationStatus.Ok)
            {
                string destPath = System.IO.Path.Combine(Environment.CurrentDirectory, @"sn.txt");
                File.WriteAllText(destPath, sn);

                var s = VMProtect.SDK.SetSerialNumber(sn);
                VMProtect.SerialNumberData sd;
                var res = VMProtect.SDK.GetSerialNumberData(out sd);
                if (res)
                {
                    //AppendResultLine("State = {0}", sd.State);
                    //AppendResultLine("User Name = {0}", sd.UserName);
                    //AppendResultLine("E-Mail = {0}", sd.EMail);
                    //AppendResultLine("Date of expiration = {0}", sd.Expires);
                    //AppendResultLine("Max date of build = {0}", sd.MaxBuild);
                    //AppendResultLine("Running time limit = {0} minutes", sd.RunningTime);
                    //AppendResultLine("Length of user data = {0} bytes", sd.UserData.Length);
                    ExpireDateTime.Content = sd.Expires.ToString();
                }
            }
            else if (status == ActivationStatus.NoConnection)
            {
                ExpireDateTime.Content = "网络连接失败,请检查网络";
            }
            else if (status == ActivationStatus.BadReply)
            {
                ExpireDateTime.Content = "激活服务器出现错误,请通知作者";
            }
            else if (status == ActivationStatus.Banned)
            {
                ExpireDateTime.Content = "此激活码已被禁止使用";
            }
            else if (status == ActivationStatus.Corrupted)
            {
                ExpireDateTime.Content = "激活服务出现异常,请通知作者";
            }
            else if (status == ActivationStatus.BadCode)
            {
                ExpireDateTime.Content = "激活失败,请检查激活码是否正确输入";
            }
            else if (status == ActivationStatus.AlreadyUsed)
            {
                ExpireDateTime.Content = "激活码已被使用";
            }
            else if (status == ActivationStatus.SerialUnknown)
            {
                ExpireDateTime.Content = "激活码不存在,请联系作者";
            }
            else if (status == ActivationStatus.Expired)
            {
                ExpireDateTime.Content = "激活码已过期";
            }
            else if (status == ActivationStatus.NotAvailable)
            {
                ExpireDateTime.Content = "激活服务失效了,请通知作者";
            }
            else
            {
                ExpireDateTime.Content = "激活失败,原因未知,请联系作者";
            }
        }