LicenseKey.vb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. Imports ComPDFKit.NativeMethod
  2. Imports System
  3. Imports System.Xml
  4. Public NotInheritable Class SDKLicenseHelper
  5. Public Shared key As String = String.Empty
  6. Public Shared secret As String = String.Empty
  7. Public Shared Function LicenseVerify() As Boolean
  8. Dim sdkLicensePath As String = "license_key_windows.xml"
  9. Dim xmlDocument As New XmlDocument()
  10. xmlDocument.Load(sdkLicensePath)
  11. Dim keyNode As XmlNode = xmlDocument.SelectSingleNode("/license/key")
  12. Dim secretNode As XmlNode = xmlDocument.SelectSingleNode("/license/secret")
  13. If keyNode IsNot Nothing AndAlso secretNode IsNot Nothing Then
  14. key = keyNode.InnerText
  15. secret = secretNode.InnerText
  16. Else
  17. Console.WriteLine("Key or secret element not found in the XML.")
  18. Return False
  19. End If
  20. Dim result As Boolean = CPDFSDKVerifier.LoadNativeLibrary()
  21. If Not result Then
  22. Return False
  23. End If
  24. Dim verifyResult As LicenseErrorCode = CPDFSDKVerifier.LicenseVerify(key, secret)
  25. If verifyResult <> LicenseErrorCode.LICENSE_ERR_SUCCESS Then
  26. Return False
  27. End If
  28. Return result
  29. End Function
  30. End Class