コード例 #1
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);
        }
コード例 #2
0
        public string UnlockedTrialwareLicense()
        {
            string StartParam = null;
            sntl_lg_license_type_t LicenseType = sntl_lg_license_type_t.SNTL_LG_LICENSE_TYPE_PROVISIONAL;
            string Definition =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                " <sentinel_ldk:license schema_version=\"1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:sentinel_ldk=\"http://www.safenet-inc.com/sentinelldk\">" +
                "   <enforcement_type>SL-AdminMode</enforcement_type>" +
                "   <product>" +
                "      <id>123</id>" +
                "      <name>Sample Product 123</name>" +
                "      <feature>" +
                "         <id>1000</id>" +
                "         <name>Sample Feature 1000</name>" +
                "         <license_properties>" +
                "            <!-- You can specify the number of days until the license expires -->" +
                "            <days_to_expiration>30</days_to_expiration>" +
                "            <!-- You can specify the remote desktop accessibility flag. Possible values are \"Yes\" or \"No\" --> " +
                "            <remote_desktop_access>Yes</remote_desktop_access>" +
                "            <!-- You can specify the virtual machine accessibility flag. Possible values are \"Yes\" or \"No\" -->" +
                "            <virtual_machine_access>No</virtual_machine_access>" +
                "         </license_properties>" +
                "      </feature>" +
                "   </product>" +
                " </sentinel_ldk:license>";
            string CurrentStateProvisional = null;

            Status = LicGenHelper.sntl_lg_start(StartParam, VendorCode, LicenseType, Definition, CurrentStateProvisional);
            if (sntl_lg_status_t.SNTL_LG_STATUS_OK != Status)
            {
                /*handle error*/
                return("StartS_" + Convert.ToString(Status));
            }
            else
            {
                string genStatus;
                genStatus = GenerationLicense();

                return(genStatus);
            }
        }