LicenseKey.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using ComPDFKit.NativeMethod;
  2. using System;
  3. using System.Xml;
  4. public static class SDKLicenseHelper
  5. {
  6. public static string key = string.Empty;
  7. public static string secret = string.Empty;
  8. public static bool LicenseVerify()
  9. {
  10. string sdkLicensePath = "license_key_windows.xml";
  11. XmlDocument xmlDocument = new XmlDocument();
  12. xmlDocument.Load(sdkLicensePath);
  13. XmlNode keyNode = xmlDocument.SelectSingleNode("/license/key");
  14. XmlNode secretNode = xmlDocument.SelectSingleNode("/license/secret");
  15. if (keyNode != null && secretNode != null)
  16. {
  17. key = keyNode.InnerText;
  18. secret = secretNode.InnerText;
  19. }
  20. else
  21. {
  22. Console.WriteLine("Key or secret element not found in the XML.");
  23. }
  24. bool result = CPDFSDKVerifier.LoadNativeLibrary();
  25. if (!result)
  26. return false;
  27. LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(key, secret);
  28. if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
  29. return false;
  30. return result;
  31. }
  32. }