Answer:

After you have initialized the licensing library, use the GetPropertyValue licensing library functions.

GetPropertyValue Function

The GetPropertyValue function gets the value for an licensing property

Syntax

UINT GetPropertyValue( 
  __in    LPCWSTR propertyName,      // name of the licensing property to be read  
  __out   LPWSTR result,             // buffer where the property value will be written
  __inout DWORD * resultLen          // capacity   
);

Parameters

  • propertyName - input parameter specifying the name of the property to be read
  • result - output parameter specifying the starting address of the buffer where the value will be written
  • resultLen - input and output parameter with the address of the variable that specifies the size, in wide characters, of the buffer pointed to by the result parameter. When the function returns 0 (ERROR_SUCCESS), this variable contains the size of the data copied to result, not including the terminating null character. If result buffer is not large enough, the function returns 234 (ERROR_MORE_DATA) and stores the required size, including the terminating null character, in the variable pointed to by resultLen

Return Value

  • 0 (ERROR_SUCCESS) - The function succeeded
  • 234 (ERROR_MORE_DATA) - The provided buffer was too small to hold the entire value and the terminating null character
  • 13 (ERROR_INVALID_DATA) - The specified property is not defined. More details about available properties you can find in the Trial and Licensing Properties article.
  • 5 (ERROR_ACCESS_DENIED) - The function call was made before the licensing initialization was performed. To see how to integrate the licensing library into your application follow our licensing articles.

Sample - C++

...
typedef UINT (__stdcall * GetPropT)(LPCWSTR, LPWSTR, DWORD *);
...
GetPropT getPropFct = reinterpret_cast<GetPropT>(::GetProcAddress(hModule, "GetPropertyValue"));

CStringW licID;
DWORD len = licID.GetAllocLength();
if ( ERROR_MORE_DATA == (getPropFct)(L"TrialName", licID.GetBuffer(), len) )
{
  (getPropFct)(L"TrialName", licID.GetBufferSetLength(len), len)
}

Sample - C#

...
[DllImport("Trial.dll", EntryPoint = "GetPropertyValue", CharSet = CharSet.Unicode)]
static extern uint GetPropertyValue(String aPropName, StringBuilder aResult, ref UInt32 aResultLen);
...
StringBuilder val = new StringBuilder();
UInt32 len2 = (UInt32) val.Capacity;
if ( GetPropertyValue( "TrialName", val, ref len2) == 234 )
{
  val.EnsureCapacity( (Int32) len2 );
  GetPropertyValue( "TrialName", val, ref len2);
}

Sample - VB

...
<DllImport("Trial.dll", EntryPoint:="GetPropertyValue", CharSet:=CharSet.Unicode)> _
Private Shared Function GetPropertyValue(ByVal aPropName As String, ByVal aResult As StringBuilder, ByRef _
  aResultLen As UInt32) As UInteger
End Function
...
Dim val As StringBuilder = New StringBuilder
Dim len As UInt32 = CType(val.Capacity, UInt32)
If GetPropertyValue("TrialName", val, len) = 234 Then
  val = New StringBuilder(CType(len, Int32))
  GetPropertyValue("TrialName", val, len)
End If

Sample - Java

public class MyMainClass {

  public native static String GetPropertyValue(String aName) throws Exception;
...
    try {
        String value = GetPropertyValue("TrialName");
        ...
    } catch (Exception e) {
        e.printStackTrace();
    }
...
}