LicenseKey.cs 1023 B

1234567891011121314151617181920212223242526272829303132333435
  1. using ComPDFKit.NativeMethod;
  2. using System.Xml;
  3. public class SDKLicenseHelper
  4. {
  5. public string key = string.Empty;
  6. public string secret = string.Empty;
  7. public SDKLicenseHelper()
  8. {
  9. string sdkLicensePath = "license_key_win.xml";
  10. XmlDocument xmlDocument = new XmlDocument();
  11. xmlDocument.Load(sdkLicensePath);
  12. var node = xmlDocument.SelectSingleNode("License");
  13. if (node != null)
  14. {
  15. key = node.Attributes["key"].Value;
  16. secret = node.Attributes["secret"].Value;
  17. }
  18. }
  19. public static bool LicenseVerify()
  20. {
  21. bool result = CPDFSDKVerifier.LoadNativeLibrary();
  22. if (!result)
  23. return false;
  24. SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
  25. LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
  26. if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
  27. return false;
  28. return result;
  29. }
  30. }