栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

在VS中引入License.dll远程激活软件或锁定软件,仅限C#

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在VS中引入License.dll远程激活软件或锁定软件,仅限C#

通过.NET库 "License.dll",你能够在运行时确定你锁定的软件的当前许可状态。你只需要在你的项目中引用这个库并访问相应的方法和属性。所有的方法和属性都应该是自我解释的。你不需要选择一个许可证文件。如果一个有效的许可证文件是可用的,它将被自动用来更新许可证状态。

"License.dll "的方法和属性只有在你保护了你的软件后才能返回正确的值。在保护之后,就不再需要 "License.dll "库了。

举个栗子:

1. VS中引入License.dll,代码中 using License;

2. 检查授权文件是否可用

public bool IsValidLicenseAvailable()
    {
        return License.Status.Licensed;
    }

3. 从一个许可证中读取额外的许可证信息:

 public void ReadAdditonalLicenseInformation()
    {
        
        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();
            }
        }
    }

4. 检查评估锁的许可证状态

public void CheckEvaluationLock()
    {
        bool lock_enabled = License.Status.Evaluation_Lock_Enabled;
        EvaluationType ev_type = License.Status.Evaluation_Type;
        int time = License.Status.Evaluation_Time;
        int time_current = License.Status.Evaluation_Time_Current;
    }

5. 检查 "到期日锁定 "的许可状态

public void CheckExpirationDateLock()
    {
        bool lock_enabled = License.Status.Expiration_Date_Lock_Enable;
        System.DateTime expiration_date = License.Status.Expiration_Date;
    }

6. 检查 "使用次数 "锁的许可状态

 public void CheckNumberOfUsesLock()
    {
        bool lock_enabled = License.Status.Number_Of_Uses_Lock_Enable;
        int max_uses = License.Status.Number_Of_Uses;
        int current_uses = License.Status.Number_Of_Uses_Current;
    }

7. 检查实例数量锁定的许可状态

  public void CheckNumberOfInstancesLock()
    {
        bool lock_enabled = License.Status.Number_Of_Instances_Lock_Enable;
        int max_instances = License.Status.Number_Of_Instances;
    }

8. 检查硬件锁的许可状态

  public void CheckHardwareLock()
    {
        bool lock_enabled = License.Status.Hardware_Lock_Enabled; 
        if (lock_enabled)
        {
            
            string lic_hardware_id  = License.Status.License_HardwareID;
        }
    }

9. 获取当前机器的硬件ID

  public string GetHardwareID()
    {
        return License.Status.HardwareID;
    }

10. 将当前的硬件ID与存储在许可证文件中的硬件ID进行比较

    public bool CompareHardwareID()
    {
        if (License.Status.HardwareID == License.Status.License_HardwareID)
            return true;
        else
            return false;
    }

11. 使许可证失效

    public void InvalidateLicense()
    {
        string confirmation_code = License.Status.InvalidateLicense();
    }

12. 检查确认码是否有效

    public bool CheckConfirmationCode(string confirmation_code)
    {
        return License.Status.CheckConfirmationCode(License.Status.HardwareID,
        confirmation_code);
    }

13.  重新激活许可证

  public bool ReactivateLicense(string reactivation_code)
    {
        return License.Status.ReactivateLicense(reactivation_code);
    }

14. 使用文件名手动加载一个许可证

    public void LoadLicense(string filename)
    {
        License.Status.LoadLicense(filename);
    }

15. 使用byte[]手动加载一个许可证

    public void LoadLicense(byte[] license)
    {
        License.Status.LoadLicense(license);
    }

16. 获取加载的许可证(如果有的话),作为byte[] 。

 public byte[] GetLicense()
    {
        return License.Status.License;   
    }

那么重要的来了,License.dll的获取方式有点扯,安装.NetReactor后在安装目录里面获得,传送门

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1023847.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号