I am using LA in my C Language application. But, when I call GetTrialDaysLeft, it always fails, no matter if I have internet connexion. Meanwhile, the trail was very well activated as I can see it through my Cryptlex account. What may lead to this function’s failure ?
int trialStatus;
trialStatus = IsTrialGenuine();
if (LA_OK == trialStatus)
{
unsigned int daysLeft = 0;
GetTrialDaysLeft(&daysLeft, LA_V_TRIAL);
printf("Trial days left: %d", daysLeft);
}
else if (LA_T_EXPIRED == trialStatus)
{
printf("Trial has expired!");
}
else
{
printf("Either trial has not started or has been tampered!");
}
GetTrialDaysLeft() is invoked only when IsTrialGenuine() returns OK
I now have an active trial but I still get Error code 1 on isTrialGenuine(). Here is the code.
int Trial_Status = 0;
unsigned int Days_Left = 0;
Trial_Status = IsTrialGenuine();
if (LA_OK == Trial_Status)
{
printf("Trial is genuine.\
");
Trial_Status = GetTrialDaysLeft(&Days_Left, LA_V_TRIAL);
printf("Trial result is %d.
", Trial_Status);
if (LA_OK == Trial_Status) printf("Get Trial Days Left worked well.\
");
if (LA_T_EXPIRED == Trial_Status) printf("Trial expired.
");
if (LA_FAIL == Trial_Status) printf("Failure getting Trial Days Left
");
asprintf(&activation_status, “Votre copie n’est pas activée.
Il vous reste %d jours d’évaluation.”, Days_Left);
} else
{
asprintf(&activation_status, “Votre copie n’est pas activée.
Cliquez sur ce bouton pour l’activer.”);
printf("Trial is not genuine. Error code %d
", Trial_Status);
Go_Trial = 1;
}
Is there anything to change ?
You are mixing it a bit. Trial days left will get stored in Days_Left and not in Trial_Status.
Use different status variables for IsTrialGenuine() and GetTrialDaysLeft() and they denote different things. You don’t need to store the status of GetTrialDaysLeft() just read the value of Days_Left variable.
I corrected de code design, but actually, the problem is a the IsTrialGenuine Level. It always fail while the trial had been really activated and is visible through my Cryptlex dashboard. Which are the cases a failure may happen for this function ?
I call ActivateTrial from a button. And on my Cryptlex dashboard, I can see as the trial is activated. But, It still doesn’t being recognized as genuine. Is it possible for a trial to be activated on Cryptlex server without being locally ?
Here is almost all the codes involved in trial activation.
if (is_activated() == 0)
{
char *activation_status;
int Trial_Status = 0;
unsigned int Days_Left = 0;
Trial_Status = SetTrialKey("####");
if (LA_OK == Trial_Status)
{
Trial_Status = ActivateTrial();
if (LA_OK != Trial_Status)
{
printf("Could not activate trial.\
");
}
Trial_Status = IsTrialGenuine();
if (LA_OK == Trial_Status)
{
printf("Trial is genuine.\
");
GetTrialDaysLeft(&Days_Left, LA_V_TRIAL);
printf("%d days remaining.\
", Days_Left);
asprintf(&activation_status, “Votre copie n’est pas activée.
Il vous reste %d jours d’évaluation.”, Days_Left);
}
else if (LA_T_EXPIRED == Trial_Status)
{
printf("Trial expired.
");
asprintf(&activation_status, “Votre copie n’est pas activée.
Votre période d’évaluation a expirée.
Allez dans les paramètres pour entrer le numéro de série”);
}
else if (LA_FAIL == Trial_Status)
{
printf("Failure calling IsTrialGenuine. Error code %d
", Trial_Status);
asprintf(&activation_status, "Votre copie n’est pas activée.
Votre logiciel n’a pas été correctement enregistré.
");
}
else
{
asprintf(&activation_status, “Votre copie n’est pas activée.
Cliquez sur ce bouton pour l’activer.”);
printf("Trial is not genuine. Error code %d
", Trial_Status);
}
}
int is_activated(void)
{
int status;
status = SetVersionGUID("####", LA_USER);
if (LA_OK != status)
{
printf("Bad version
");
getchar();
return 0;
}
status = IsProductActivated();
if (LA_OK != status)
{
printf("Product is not activated.
");
return 0;
}
status = IsProductGenuine();
if (LA_OK != status)
{
if (LA_EXPIRED == status) printf("Product expired
");
if (LA_REVOKED == status) printf("Product revoked
");
if (LA_GP_OVER == status) printf("Product grace period is over
");
if (LA_FAIL == status) printf("Product failed verification
");
printf("Not Genuine. Error code %d
", status);
return 0;
}
else
{
printf("Product is genuine.
");
}
return 1;
}
It seems you have activated the product using Product key as well as you are activating the trial. If product is activated trial won’t be valid. You should deactivate the product using DeactivateProduct() and then activate the trial.
Actually the product is not activated in my development computer but I installed a new computer where the software did never run and where I made no activation before activating Trial. The result is same. If ever you have a working sample C application please provide me.
I copy pasted code from sample.cpp changing only product and trial keys. This is what happened : first, the sample code has a bug on line 41 where LA_OK is compared against the status variable instead of trialStatus. Second, even after that, I still get 0 days as result. On two different computers with no product activation.