Exemple #1
0
        private void Form_Main_Load(object sender, EventArgs e)
        {
            this.Text          = this.Text.Replace("{vv}", ProgramVersion);
            RB_DefaultMix.Text = RB_DefaultMix.Text.Replace("{xx}", defaultNumberOfLic.ToString());
            RB_DefaultMix.Text = RB_DefaultMix.Text.Replace("{yy}", defaultNumberOfLic.ToString());
            RB_DefaultMix.Text = RB_DefaultMix.Text.Replace("{zz}", defaultNumberOfLic.ToString());
            RB_DefaultSL.Text  = RB_DefaultSL.Text.Replace("{xx}", defaultNumberOfLic.ToString());
            RB_DefaultSL.Text  = RB_DefaultSL.Text.Replace("{yy}", defaultNumberOfLic.ToString());
            RB_DefaultHL.Text  = RB_DefaultHL.Text.Replace("{zz}", defaultNumberOfLic.ToString());

            P_CustomSettings.Visible = false;
            B_Start.Enabled          = false;
            LocalActivation          = defaultNumberOfLic;
            NetworkActivationSL      = defaultNumberOfLic;
            NetworkActivationHL      = defaultNumberOfLic;
            UnlockedTrialware        = true;

            Status = LicGenHelper.sntl_lg_initialize(InitParam);
            if (sntl_lg_status_t.SNTL_LG_STATUS_OK != Status)
            {
                /*handle error*/
                TB_Logs.Text = TB_Logs.Text + "LicGen API initialization error: " + Status;
            }
            else
            {
                TB_Logs.Text = TB_Logs.Text + "LicGen API initialization is successfully.";
            }
        }
Exemple #2
0
        public string CheckMaster(string license = null)
        {
            if (!CheckDogStatus())
            {
                return("未检测到超级狗");
            }

            string info      = null;
            var    dogStatus = _dog.GetSessionInfo(Dog.UpdateInfo, ref info);

            if (dogStatus != DogStatus.StatusOk || string.IsNullOrEmpty(info))
            {
                return("超级狗信息读取失败");
            }

            _licGenApiHelper = new LicGenAPIHelper();

            var licGenStatus = _licGenApiHelper.sntl_lg_initialize(null);

            if (licGenStatus != sntl_lg_status_t.SNTL_LG_STATUS_OK)
            {
                _licGenApiHelper.sntl_lg_cleanup();
                return("初始化许可失败");
            }

            licGenStatus = _licGenApiHelper.sntl_lg_start(null, SuperDogVendorCode.VendorCode,
                                                          sntl_lg_license_type_t.SNTL_LG_LICENSE_TYPE_FORMAT_AND_UPDATE, license, info);
            if (licGenStatus != sntl_lg_status_t.SNTL_LG_STATUS_OK)
            {
                _licGenApiHelper.sntl_lg_cleanup();

                switch (licGenStatus)
                {
                case sntl_lg_status_t.SNTL_LG_INVALID_VENDOR_CODE:
                    return("无效的开发商代码");

                case sntl_lg_status_t.SNTL_LG_MASTER_KEY_IO_ERROR:
                    return("未检测到开发狗");

                case sntl_lg_status_t.SNTL_LG_MASTER_KEY_CONNECT_ERROR:
                case sntl_lg_status_t.SNTL_LG_MASTER_KEY_ACCESS_ERROR:
                    return("连接开发狗发生错误");

                default:
                    return("加载许可失败");
                }
            }

            if (string.IsNullOrEmpty(license))
            {
                _licGenApiHelper.sntl_lg_cleanup();
            }

            return(null);
        }