.net reactor 学习系列(二)—.net reactor代码自动操作相关保护功能

接上篇,上篇已经学习了界面的各种功能以及各种配置,这篇准备学习下代码控制许可证。

复制代码
///
/// 创建许可证
///
///
private void CreateLicenseFile()
{
LicenseGenerator licensegen = new LicenseGenerator();
licensegen.AddAdditonalLicenseInformation(“Company”, “Eye”);
licensegen.Hardware_Enabled = true;
licensegen.HardwareID = “1234-1234-1234-1234-1234”;
licensegen.CreateLicenseFile(@“C:newlicense.license”);
}
复制代码
这将会在c盘下生成newlicense.license许可证文件,文件的内容包括添加进去的键值对Company-Eye,开启硬件锁,此许可证只针对硬件编码为1234-1234-1234-1234-1234的机器有效。

复制代码
///
/// 许可证是否可用
///
///
private bool IsValidLicenseAvailable()
{
return License.Status.Licensed;
}

///
/// 获取许可证键值信息
///
private string ReadAdditonalLicenseInformation()
{
string rtnStr = string.Empty;
if (License.Status.Licensed)
{
for (int i = 0; i {
string key = License.Status.KeyValueList.GetKey(i).ToString();
string value = License.Status.KeyValueList.GetByIndex(i).ToString();

}

///
/// 获取软件锁定信息
///
///
private string ReadLockMsg()
{
string rtnStr = string.Empty;
//使用持续时间锁
bool lock_enabled = License.Status.Evaluation_Lock_Enabled;
License.EvaluationType ev_type = License.Status.Evaluation_Type;
int time = License.Status.Evaluation_Time;
int time_current = License.Status.Evaluation_Time_Current;
rtnStr += string.Format(“是否开启持续时间锁:{0},规定使用最大持续时间{1},现在使用时间{2}n”,lock_enabled.ToString(),time.ToString(),time_current.ToString());

}

///
/// 获取机器硬件编号
///
///
private string GetHardwareID()
{
return License.Status.HardwareID;
}

///
/// 获取许可证适用的硬件编码
///
///
private string GetLicenseHardwareID()
{
return License.Status.License_HardwareID;
}

///
/// 作废许可证
///
private string InvalidateLicense()
{
string confirmation_code = License.Status.InvalidateLicense();
return confirmation_code;
}

///
/// 检查作废许可证的验证码是否有效
///
///
///
public bool CheckConfirmationCode(string confirmation_code)
{
return License.Status.CheckConfirmationCode(License.Status.HardwareID,
confirmation_code);
}

///
/// 重新激活许可证
///
///
///
public bool ReactivateLicense(string reactivation_code)
{
return License.Status.ReactivateLicense(reactivation_code);
}
复制代码
其中作废许可证及激活许可证的主要应用场景是:如果许可证开启硬件锁,客户端想从一个机器移动许可证到另一个机器此时就需要先作废许可证,然后在新机器里重新激活许可证。作废许可证可直接调用即可,但是激活许可证需要打开Tools->LicenseReactivation Tool来根据硬件编码生成激活码,传入即可激活许可证。(这里生成激活码我只找到在工具里可视化操作,在代码中找不到这种方法,所以这个应用场景不太适合许可证全自动化的管理)。

来源:北理_哄哄

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年5月12日
下一篇 2019年5月12日

相关推荐