Licensing实例(一)

这篇博客主要提供了一个关于licensing的代码实例,作者并未详细阐述背景,而是直接通过带有注释的代码来展示其用法。若读者感兴趣,可以自行研究代码中的注释以获取更多信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

说明:由于人很懒,并且时间的关系。我不一一说明前因后果。一般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
            
{
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值