第08章 许可证管理系统

第08章:许可证管理系统

8.1 许可证系统概述

.NET Reactor 内置完整的软件许可证管理系统,支持多种许可证模式和验证方式。

8.1.1 许可证类型

  1. 试用许可证(Trial License)

    • 时间限制
    • 功能限制
    • 使用次数限制
  2. 完整许可证(Full License)

    • 永久使用
    • 完整功能
    • 硬件锁定
  3. 订阅许可证(Subscription)

    • 按月/按年
    • 自动续期
    • 在线验证
  4. 浮动许可证(Floating License)

    • 并发用户数限制
    • 许可证服务器
    • 网络验证

8.2 配置许可证

基本配置:

Settings → Licensing → License Configuration

☑ Enable Licensing

License Type:
● Trial (30 days)
○ Full License
○ Subscription
○ Floating

Validation Method:
☑ Online Validation
☑ Offline Validation
☑ Hardware Lock

8.3 许可证生成

生成试用许可证:

Tools → License Generator

Trial Settings:
- Duration: [30] days
- Features: [All]
- Max Uses: [Unlimited]

Generate → trial.license

8.4 代码集成

检查许可证:

using System;

namespace MyApp
{
    public class LicenseChecker
    {
        public static bool CheckLicense()
        {
            // .NET Reactor 自动注入的方法
            if (!LicenseManager.IsLicensed())
            {
                Console.WriteLine("No valid license found!");
                return false;
            }
            
            // 获取许可证信息
            var info = LicenseManager.GetLicenseInfo();
            Console.WriteLine($"Licensed to: {info.Name}");
            Console.WriteLine($"Valid until: {info.ExpirationDate}");
            
            return true;
        }
    }
}

8.5 在线激活

实现在线激活:

Settings → Licensing → Online Activation

Activation Server: [https://activation.example.com]
API Key: [your-api-key]

☑ Require Internet Connection
☑ Validate on Startup
☑ Periodic Validation (每7天)

8.6 硬件锁定

配置硬件锁定:

Licensing → Hardware Lock

Lock to:
☑ CPU ID
☑ MAC Address
☑ Motherboard ID
☐ Hard Drive Serial

Tolerance: [Strict ▼]

8.7 许可证服务器

部署许可证服务器:

1. 安装 .NET Reactor License Server
2. 配置数据库连接
3. 设置端口和 SSL
4. 导入许可证数据
5. 客户端配置服务器地址

8.8 自定义许可证界面

创建激活窗口:

public class ActivationDialog : Form
{
    private TextBox txtLicenseKey;
    private Button btnActivate;
    
    public ActivationDialog()
    {
        InitializeUI();
    }
    
    private void btnActivate_Click(object sender, EventArgs e)
    {
        string key = txtLicenseKey.Text;
        
        if (LicenseManager.ActivateOnline(key))
        {
            MessageBox.Show("Activation successful!");
            this.DialogResult = DialogResult.OK;
        }
        else
        {
            MessageBox.Show("Activation failed!");
        }
    }
}

8.9 本章小结

本章详细介绍了 .NET Reactor 的许可证管理系统,包括各种许可证类型、配置方法、代码集成和在线激活等内容。

posted @ 2025-12-20 13:37  我才是银古  阅读(2)  评论(0)    收藏  举报