Date in custom license field is expired, but app is still working

Hello!I am using Delphi 7.And I have a custom field - "license_date_end". I am checking it like this:"if (isGenuine) then begin Exp_date := ta.GetFeatureValue(PWideChar(WideString('license_date_end'))); if ta.IsDateValid(Exp_date, TA_HAS_NOT_EXPIRED) then ShowMessage('expired') else ShowMessage('not expired'); end;"Exp_date is widestring. I can't write "Exp_date := ta.GetFeatureValue('license_date_end')"because in this case I'm getting error"There is no overloaded version of "GetFeautureValue", the input variable of GetFeautureValue is PWideChar.What shall I do?

We're updating the Delphi example to make things easier. In the meantime here's an example of reading and using a custom license field:

if isGenuine then begin // read in a custom license field named "update_expires" featureValue := ta.GetFeatureValue('update_expires', '');

// if the date has passed then kill the app immediately if (featureValue = '') Or (not ta.IsDateValid(featureValue, TA_HAS_NOT_EXPIRED)) then begin ShowMessage('Your subscription has expired. Buy a renewal.');

// Exit the app, and exit the function immediately Application.Terminate; exit; end; end;

And you'll need to modify the TurboActivateUnit.pas to directly use WideStrings rather than pointers. We'll include this in the updated delphi example (out with the next version of TurboActivate). Here it is in the meantime:

/// <summary>/// Gets the value of a feature./// </summary>/// <param name="featureName">The name of the feature to retrieve the value for.</param>{$IFDEF MACOS}function TurboActivate.GetFeatureValue(featureName: s): UnicodeString;{$ELSE}function TurboActivate.GetFeatureValue(featureName: WideString): WideString;{$ENDIF}var{$IFDEF MACOS} value : UnicodeString;{$ELSE} value : WideString;{$ENDIF}begin value := GetFeatureValue(featureName, '');

if (value = '') then begin raise ETurboActivateException.Create('Failed to get feature value. The feature doesn''t exist.'); end;

Result := value;end;

/// <summary>/// Gets the value of a feature./// </summary>/// <param name="featureName">The name of the feature to retrieve the value for.</param>/// <param name="defaultValue">The default value to return if the feature doesn't exist.</param>{$IFDEF MACOS}function TurboActivate.GetFeatureValue(featureName: UnicodeString; defaultValue: UnicodeString): UnicodeString;{$ELSE}function TurboActivate.GetFeatureValue(featureName: WideString; defaultValue: WideString): WideString;{$ENDIF}var ret : LongInt;{$IFDEF MACOS} featValue : PAnsiChar;{$ELSE} featValue : PWideChar;{$ENDIF}begin

{$IFDEF MACOS} // get the length of the string we need to allocate ret := TurboActivateUnit.TA_GetFeatureValue(self.handle, PAnsiChar(featureName), nil, 0);

// make the string featValue := AnsiStrAlloc(ret);

// get the string ret := TurboActivateUnit.TA_GetFeatureValue(self.handle, PAnsiChar(featureName), featValue, ret); {$ELSE} // Windows // get the length of the string we need to allocate ret := TurboActivateUnit.TA_GetFeatureValue(self.handle, PWideChar(featureName), nil, 0);

// make the string {$IF CompilerVersion >= 20} // for Delphi 2009 + featValue := StrAlloc(ret); {$ELSE} featValue := PWideChar(StrAlloc(ret * 2 + 2)); {$IFEND}

// get the string ret := TurboActivateUnit.TA_GetFeatureValue(self.handle, PWideChar(featureName), featValue, ret); {$ENDIF}

// free the string if an error happens if (ret <> 0) then begin {$IF CompilerVersion >= 20} // for Delphi 2009 + StrDispose(featValue); {$ELSE} StrDispose(PChar(featValue)); {$IFEND} end;

case ret of TA_E_INVALID_HANDLE: raise EInvalidHandleException.Create(); TA_OK: // success

{$IFDEF MACOS} Result := System.Utf8ToUnicodeString(featValue); {$ELSE} // Windows Result := featValue; {$ENDIF} else Result := defaultValue; end;end;

It's works thanks!

Tell me please what to do next. For example "update_expires" is valid, what a customer shall to do? He pays me for a next year, and I am updating the field "update_expires" and then? He need to re-verify or what?P.S. My customers does not always have internet access.

This is covered in the custom license fields article: https://wyday.com/limelm/help/license-features/#change-datetime