License information

Pepescri

New member
I would like to include in an application a button that can open a form and the user can check the type of license (demo, annual, or unlimited), the expiration date, and their activation code. All three versions are hardware-protected. I have created the form and the function calls using commands like:

Public Function PL_ActivationKey() As String
On Error Resume Next
PL_ActivationKey = Application.Run("XLSPL_GetActivationKey")
End Function

But I don't get any results. Has anyone managed it?
 
Solution
The function you're calling, XLSPL_GetActivationKey, does not exist in XLS Padlock — that's why Application.Run returns nothing. The same applies to names like XLSPL_GetLicenseExpirationDate. Copilot has likely invented them.

The real VBA API is exposed through the GXLSForm.GXLSFormula COM add-in, and you query values with PLEvalVar(...). Here are the fields that are actually available at runtime:

  • PLEvalVar("IsTrial") — returns True if the EXE is running as a trial key, False if it's registered
  • PLEvalVar("TrialState") — remaining days (or executions) for the current key; works for both trial keys and registered keys that have an expiration date / run limit...
The function you're calling, XLSPL_GetActivationKey, does not exist in XLS Padlock — that's why Application.Run returns nothing. The same applies to names like XLSPL_GetLicenseExpirationDate. Copilot has likely invented them.

The real VBA API is exposed through the GXLSForm.GXLSFormula COM add-in, and you query values with PLEvalVar(...). Here are the fields that are actually available at runtime:

  • PLEvalVar("IsTrial") — returns True if the EXE is running as a trial key, False if it's registered
  • PLEvalVar("TrialState") — remaining days (or executions) for the current key; works for both trial keys and registered keys that have an expiration date / run limit
  • PLEvalVar("SystemID") — the user's hardware System ID
Important limitations, on purpose:

  • There is no API to retrieve the actual activation key string at runtime — that would defeat the hardware-locking protection
  • There is no API to return the exact expiration date as a date; use TrialState (remaining days/runs) instead
Example of a function you can wire to your button:

Code:
Public Sub ShowLicenseInfo()
    Dim XLSPadlock As Object
    Dim licType As String
    Dim remaining As Variant
    Dim sysID As String

    On Error Resume Next
    Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
    On Error GoTo 0

    If XLSPadlock Is Nothing Then
        MsgBox "License info is only available when running the compiled EXE."
        Exit Sub
    End If

    If XLSPadlock.PLEvalVar("IsTrial") Then
        licType = "Trial / Demo"
    Else
        licType = "Registered (annual or unlimited)"
    End If

    remaining = XLSPadlock.PLEvalVar("TrialState")
    sysID = XLSPadlock.PLEvalVar("SystemID")

    MsgBox "License type: " & licType & vbCrLf & _
           "Remaining days/runs: " & remaining & vbCrLf & _
           "System ID: " & sysID
End Sub
A couple of notes that apply to your three license variants (demo, annual, unlimited), all hardware-locked:

  • IsTrial only returns True for keys that were generated as trial keys with the nag screen option. Your "annual" keys should be generated as registered keys with an expiration date — for those, IsTrial returns False and you read the remaining time from TrialState.
  • To distinguish "annual" vs "unlimited" on the UI side, the cleanest approach is to use a different product (or a different key prefix) for each plan, or to encode the plan in a custom field of the key — XLS Padlock cannot tell "annual" and "unlimited" apart by itself, since an unlimited key simply has no expiration.
  • PLEvalVar returns an empty value when running the .xlsm directly in Excel, so always check that the COM object is available before reading fields. That's why your On Error Resume Next version silently returned nothing during tests outside the EXE.
Take a look at https://www.xlspadlock.com/doc/vba-api-cookbook
 
Solution
Back
Top