原文:.net reactor 学习系列(三)---.net reactor代码自动操作相关保护功能

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

        代码控制许可证的意思就是软件经过.net reactor保护后,到期时客户端就需要购买许可证,这时软件开发商就需要生成许可证等操作,这个操作可以由代码控制来达到自动化的效果。当然不仅仅是生成操作,还包扩获取许可证的信息,作废许可证,激活许可证等操作。

        在安装目录下...\.NET Reactor\SDK\Binaries文件夹下可以找到License.dll和LicenseGen.dll(.net编写 .net reactor是一个.net 编写的程序)。其中License.dll主要用于获取许可证信息,作废许可证,激活许可证等,可整合到软件项目中,而LicenseGen.dll主要用于生成许可证,不可整合,可以用于许可证自动生成的服务。

        首先看下许可证生成代码:

        /// <summary>
/// 创建许可证
/// </summary>
/// <param name="project_filename"></param>
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的机器有效。

        再来看看License.dll的功能:

        /// <summary>
/// 许可证是否可用
/// </summary>
/// <returns></returns>
private bool IsValidLicenseAvailable()
{
return License.Status.Licensed;
} /// <summary>
/// 获取许可证键值信息
/// </summary>
private string ReadAdditonalLicenseInformation()
{
string rtnStr = string.Empty;
if (License.Status.Licensed)
{
for (int i = 0; i < License.Status.KeyValueList.Count; i++)
{
string key = License.Status.KeyValueList.GetKey(i).ToString();
string value = License.Status.KeyValueList.GetByIndex(i).ToString(); rtnStr += key + "-" + value + Environment.NewLine;
}
}
return rtnStr;
} /// <summary>
/// 获取软件锁定信息
/// </summary>
/// <returns></returns>
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()); //到期锁
bool lock_enabled1 = License.Status.Expiration_Date_Lock_Enable;
System.DateTime expiration_date = License.Status.Expiration_Date;
rtnStr += string.Format("是否开启到期锁:{0},到期时间{1}\n", lock_enabled1.ToString(), expiration_date.ToShortTimeString()); //使用次数锁
bool lock_enabled2 = License.Status.Number_Of_Uses_Lock_Enable;
int max_uses = License.Status.Number_Of_Uses;
int current_uses = License.Status.Number_Of_Uses_Current;
rtnStr += string.Format("是否开启使用次数锁:{0},最大使用次数{1},当前使用次数{2}\n", lock_enabled2.ToString(), max_uses.ToString(), current_uses.ToString()); //并发运行锁
bool lock_enabled3 = License.Status.Number_Of_Instances_Lock_Enable;
int max_instances = License.Status.Number_Of_Instances;
rtnStr += string.Format("是否限制并行数量:{0},最大并行数量:{1}\n", lock_enabled3, max_instances.ToString()); //硬件锁
bool lock_enabled4 = License.Status.Hardware_Lock_Enabled;
string lic_hardware_id = "";
if (lock_enabled)
{
lic_hardware_id = License.Status.License_HardwareID;
}
rtnStr += string.Format("证书是否开启硬件锁{0},对于特定硬件的有效{1}\n", lock_enabled4.ToString(), lic_hardware_id);
return rtnStr;
} /// <summary>
/// 获取机器硬件编号
/// </summary>
/// <returns></returns>
private string GetHardwareID()
{
return License.Status.HardwareID;
} /// <summary>
/// 获取许可证适用的硬件编码
/// </summary>
/// <returns></returns>
private string GetLicenseHardwareID()
{
return License.Status.License_HardwareID;
} /// <summary>
/// 作废许可证
/// </summary>
private string InvalidateLicense()
{
string confirmation_code = License.Status.InvalidateLicense();
return confirmation_code;
} /// <summary>
/// 检查作废许可证的验证码是否有效
/// </summary>
/// <param name="confirmation_code"></param>
/// <returns></returns>
public bool CheckConfirmationCode(string confirmation_code)
{
return License.Status.CheckConfirmationCode(License.Status.HardwareID,
confirmation_code);
} /// <summary>
/// 重新激活许可证
/// </summary>
/// <param name="reactivation_code"></param>
/// <returns></returns>
public bool ReactivateLicense(string reactivation_code)
{
return License.Status.ReactivateLicense(reactivation_code);
}

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

        本文代码下载地址:http://yunpan.cn/cJnMmILrX9Av2 访问密码 2585

        下一篇主要学习下.net reactor的简单应用场景

.net reactor 学习系列(三)---.net reactor代码自动操作相关保护功能的更多相关文章

  1. [转].net reactor 学习系列(三)---.net reactor代码自动操作相关保护功能

    接上篇,上篇已经学习了界面的各种功能以及各种配置,这篇准备学习下代码控制许可证. 代码控制许可证的意思就是软件经过.net reactor保护后,到期时客户端就需要购买许可证,这时软件开发商就需要生成 ...

  2. .net reactor 学习系列(二)---.net reactor界面各功能说明

    原文:.net reactor 学习系列(二)---.net reactor界面各功能说明         安装了.net reactor之后,可以在安装目录下找到帮助文档REACTOR_HELP.c ...

  3. .net reactor 学习系列(一)---.net reactor介绍

    原文:.net reactor 学习系列(一)---.net reactor介绍       学习.net已经一年多了,从语言的编写到框架类库的运用再到.net三大解决方案的了解(WF,WCF,WPF ...

  4. .net reactor 学习系列(四)---.net reactor应用场景

    原文:.net reactor 学习系列(四)---.net reactor应用场景         前面已经学习了.net reactor一些基础知识,现在准备学习下实际的应用场景,只是简单的保护和 ...

  5. [转].net reactor 学习系列(二)---.net reactor界面各功能说明

    安装了.net reactor之后,可以在安装目录下找到帮助文档REACTOR_HELP.chm,目前没有中文版本,里面详细介绍了.net reactor的各功能及使用场景.本系列文章是基于此帮助文档 ...

  6. Spring学习系列(三) 通过Java代码装配Bean

    上面梳理了通过注解来隐式的完成了组件的扫描和自动装配,下面来学习下如何通过显式的配置的装配bean 二.通过Java类装配bean 在前面定义了HelloWorldConfig类,并使用@Compon ...

  7. [转].net reactor 学习系列(四)---.net reactor应用场景

    前面已经学习了.net reactor一些基础知识,现在准备学习下实际的应用场景,只是简单的保护和许可证发放场景.如果想应用更高级的场景比如自动化程序许可证的发放及自定义客户端的过期提示等等就需要自己 ...

  8. RabbitMQ学习系列三-C#代码接收处理消息

    RabbitMQ学习系列三:.net 环境下 C#代码订阅 RabbitMQ 消息并处理 http://www.80iter.com/blog/1438251320680361 http://www. ...

  9. MyBatis学习系列三——结合Spring

    目录 MyBatis学习系列一之环境搭建 MyBatis学习系列二——增删改查 MyBatis学习系列三——结合Spring MyBatis在项目中应用一般都要结合Spring,这一章主要把MyBat ...

随机推荐

  1. java开发中序列化与反序列化起到的作用

    基本概念: 序列化是将对象状态转换为可保持或传输的格式的过程.与序列化相对的是反序列化,它将流转换为对象. 这两个过程结合起来,能够轻松地存储和数据传输. 特别在网络传输中,它的作用显得尤为重要.我们 ...

  2. ios开发网络学习九:NSURLSessionDownloadTask实现大文件下载

    一:NSURLSessionDownloadTask:实现文件下载:无法监听进度 #import "ViewController.h" @interface ViewControl ...

  3. thinkphp3.1 发送email

    //*********************发送邮件************************** Vendor('email'); //******************** 配置信息 * ...

  4. &lt;LeetCode OJ&gt; 62. / 63. Unique Paths(I / II)

    62. Unique Paths My Submissions Question Total Accepted: 75227 Total Submissions: 214539 Difficulty: ...

  5. jquery-6 jquery属性选择器

    jquery-6 jquery属性选择器 一.总结 一句话总结:jquery操作就是选择器加jquery对象的各种方法. 1.大量操作样式用什么方式? 大批量样式通过加类和减类完成 2.jquery中 ...

  6. [NPM] Run npm scripts with git hooks

    In this lesson we will look about how we can integrate with git hooks to help enforce a certain leve ...

  7. dom对象常用的属性和方法有哪些?

    dom对象常用的属性和方法有哪些? 一.总结 一句话总结: 1.document属性和方法:document的属性有head,body之类,方法有各种获取element的方法 2.element的属性 ...

  8. gen_server笔记

    http://www.ask3.cn/a/jingcaibowen/tech/Erlang/2013/0614/42043.html gen_server是erlang的OTP框架中最常用的“行为模式 ...

  9. Java对象基础的一些小问题

    1 权限修饰符public protected private default..访问权限修饰符   public protected default private 同类 T T T T 同包 T ...

  10. MapReduce wordcount 输入路径为目录 java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$POSIX.stat(Ljava/lang/String;)Lorg/apache/hadoop/io/nativeio/NativeIO$POSIX$Stat;

    之前windows下执行wordcount都正常,今天执行的时候指定的输入路径是文件夹,然后就报了如题的错误,把输入路径改成文件后是正常的,也就是说目前的wordcount无法对多个文件操作 报的异常 ...