IsLicenseGenuine failing inside service application


#1

Hello,

The following code works fine for us in a typical Windows user application (both elevated and standard rights) however inside our Windows service it’s failing at the license check APIs. We’ve toggled lfUser to lfSystem (as the docs state) but we see no difference. We get the same error despite what flag used.

Are we needing to do something else here??? The only way I see this working for us from a service is if we spawn a user process and pipe the information of the license check back to the service. We’d prefer not to have to do that, though.

Code and debug output is below:

function IsProductActive(): BOOL; stdcall;
var
Status: TLAKeyStatus;
begin
result := False;

SetLastError(0);

SetProductData(PRODUCT_DAT_FILE);

OutputDebugString(PChar('SetProductData() - ’ + SysErrorMessage(GetLastError())));

SetProductId(PRODUCT_ID, lfSystem);

OutputDebugString(PChar('SetProductId() - ’ + SysErrorMessage(GetLastError())));

SetAppVersion(PRODUCT_VERSION);

OutputDebugString(PChar('SetAppVersion() - ’ + SysErrorMessage(GetLastError())));

Status := IsLicenseGenuine();

OutputDebugString(PChar('IsLicenseGenuine() - ’ + SysErrorMessage(GetLastError())));

if Status in [lkOK, lkGracePeriodOver] then
begin
result := True;
Exit;
end;

Status := IsTrialGenuine();

OutputDebugString(PChar('IsTrialGenuine - ’ + SysErrorMessage(GetLastError())));

result := Status = lkOK;
end;

Debug Output:

00000001 0.00000000 [6948] SetProductData() - The operation completed successfully
00000002 0.00034490 [6948] SetProductId() - The operation completed successfully
00000003 0.00035400 [6948] SetAppVersion() - The operation completed successfully
00000004 0.00370580 [6948] IsLicenseGenuine() - There are no more files
00000005 0.00395930 [6948] IsTrialGenuine - There are no more files

Win32 Error Code Information:

ERROR_NO_MORE_FILES
18 (0x12)
There are no more files.


#2

Hi,

Did you try activating the license from your service app? What does ActivateLicense() function return when called from your service app?


#3

No, the license was only activated from a user app. To be more specific we used the GitHub Delphi code example located here https://github.com/cryptlex/lexactivator-delphi


#4

You need to activate the license from your service app.