Licensing实例(一)

说明:由于人很懒,并且时间的关系。我不一一说明前因后果。一般blog上的都是代码实例。如果你们认为有用,自己看一下注释:)

 

     /// <summary>
    
/// 试用警告
    
/// </summary>

     public   class  EvaluationMonitor : IDisposable
    
{
        
private RegistryKey _baseKey;
        
private static byte[] _desIV = new byte[] 0xa30xef0xd60x210x370x800xcc0xb1 };
        
private static byte[] _desKey = new byte[] 0x120x750xa80xf1500xed0x130xf2 };
        
private DateTime _firstUseDate;
        
private string _firstUseKeyName;
        
private bool _invalid;
        
private DateTime _lastUseDate;
        
private string _lastUseKeyName;
        
private byte[] _productData;
        
private RegistryKey _rootKey;
        
private int _usageCount;
        
private string _usageKeyName;
        
private const string classFirstUseKey = "Cobainsoft";
        
private const string classLastUseKey = "Control";
        
private const string classUsageKey = "TypeLib";
        
private const string userFirstUseKey = @"SoftwareMicrosoftWABWAB Sort State";
        
private const string userLastUseKey = @"SoftwareMicrosoftWABWAB4LastFind";
        
private const string userUsageKey = @"SoftwareMicrosoftWABWAB4";


        
/// <summary>
        
/// 初始化一个试用警告。
        
/// </summary>
        
/// <param name="productID"></param>

        public EvaluationMonitor(string productID)
        
{
            RegistryKey key1;
            
this._usageCount = 0;
            
this._firstUseDate = DateTime.MinValue;
            
this._lastUseDate = DateTime.MinValue;
            
this._invalid = false;
            
this._productData = this.Encrypt(productID);
            
try
            
{
                Registry.ClassesRoot.CreateSubKey(productID);
                Registry.ClassesRoot.DeleteSubKey(productID, 
false);
                
this._rootKey = Registry.ClassesRoot;
                key1 
= this._rootKey.OpenSubKey("CLSID"true);
                
this._usageKeyName = "TypeLib";
                
this._firstUseKeyName = "Cobainsoft";
                
this._lastUseKeyName = "Control";
            }

            
catch
            
{
                
this._rootKey =
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值