原創|使用教程|編輯:何躍|2021-08-23 11:16:52.570|閱讀 594 次
概述:License.dll - 通過這個.NET庫,你能夠在運行時確定你鎖定的軟件的當前許可狀態。你還能夠提取當前機器的硬件ID并使許可證失效。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
"License.dll "的方法和屬性只有在你保護了你的軟件后才能返回正確的值。在保護之后,就不再需要 "License.dll "庫了。
舉個栗子:
1. VS中引入License.dll,代碼中 using License;
2. 檢查授權文件是否可用
public bool IsValidLicenseAvailable() { return License.Status.Licensed; }3. 從一個許可證中讀取額外的許可證信息:
public void ReadAdditonalLicenseInformation() { /* Check first if a valid license file is found */ if (License.Status.Licensed) { /* Read additional license information */ 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) { /* Get Hardware ID which is stored inside the license file */ 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; }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn