SetDayIntervalForServerCheck is not working

Hi, I’m new on cryptlex, while I’m using the sample C++ project to do some testing.
While i’m setting the it to 1 day. I still get the license is genuinely activated! even I deactivate the license in Web more than 1 day. Is there any wrong on my script.

status = SetVersionGUID(L"xxxx-xxxx-xxxx-xxxx-xxxxxxx", LA_USER);
SetDayIntervalForServerCheck(1);
SetGracePeriodForNetworkError(10);

Hi,

If you deactivate the license, and don’t consume the license on some other pc, it would get reactivated. You have to revoke the key, if you want to invalidate the license on the client.

Hi,

I tried to activate the license in other machine already. The original machine keep give out the “Product is genuinely activated!” in sample code after 48hrs, even I put SetDayIntervalForServerCheck(1); before status = IsProductGenuine();

status = SetVersionGUID(L"xxxx-xxxx-xxxx-xxxx-xxxxxxx", LA_USER);
status = SetDayIntervalForServerCheck(1);
status = IsProductGenuine();

if (LA_OK != status) {
printf(“Error code: %d”, status);
getchar();
return status;
}

Anything wrong in the code??

Hi,

Create a license key with validity of 365 days (say).

Activate your app using the license key.

SetDayIntervalForServerCheck(1);

Revoke the key in the dashboard. After one day start your app again, keep it open for atleast 20 seconds. Restart your app and you will see that software is deactivated.

Dear there, I’m adding status = SetDayIntervalForServerCheck(1); in the following C++ script based on tutorial script.
After activation on machine1, we deactivate the license through dashboard, and let machine2 activate the license.
After a day, machine1 run the program again, and it still fall into “Product is genuinely activated!”, is there any problem on my script? Thank you.

if(LA_OK != status) {
	printf(" Error code2: %d",status); 
	getchar();
	return status;
}


status = IsProductGenuine();

#include <stdio.h>
#include <stdlib.h>
#include “LexActivator.h”
#include <Winbase.h>

#if _WIN32
#if _WIN64
#pragma comment(lib,“x64/LexActivator”)
#else
#pragma comment(lib,“x86/LexActivator”)
#endif
#endif

int main()
{

int status;

status = SetProductFile(L"xxx.dat");
printf(" SetProductFile status:", status);
if(LA_OK != status) {
	printf("Error code: %d",status); 
	getchar();
	return status;
}
status = SetVersionGUID(L"xxxxxxx", LA_USER);
status = SetDayIntervalForServerCheck(1);
status = SetGracePeriodForNetworkError(1);

if(LA_OK != status) {
	printf(" Error code2: %d",status); 
	getchar();
	return status;
}


status = IsProductGenuine();
printf(" IsProductGenuine status:", status);
if(LA_OK == status) {
	printf(" Product is genuinely activated!");  
	//status = SetProductKey(L"xxxxxxxxx");
	//status = ActivateProduct();

}
else if(LA_EXPIRED == status) {
	printf(" Product is genuinely activated, but license validity has expired!");  
}
else if(LA_GP_OVER == status) {
	printf(" Product is genuinely activated, but grace period is over!");  
}
else {

	// Time to buy the product key and activate the app
	status = SetProductKey(L"xxxxxxx");
	
	if (LA_OK != status) {
		printf("Error code: %d", status);
		getchar();
		return status;
	}

	SetExtraActivationData(L"QM 1.0");
	// Activating the product
	status = ActivateProduct();    // Ideally on a button click inside a dialog
	printf(" ActivateProduct status:", status);
	if (LA_OK == status) {
		printf("Product activated successfully!");
	}
	else {
		printf("Product activation failed: %d", status);
	}
	
}     
getchar();
return 0;

}

You are calling ActivateProduct () after IsProductGenuine () which is incorrect. The ActivateProduct () function should only be called once and not on every restart.

When you will restart your app third time then it will show invalid license, because IsProductGenuine () returns the result by validating local data, and also creates a thread to validate on server asynchronously. So it would invalidate data on second start, and when you restart third time the local data will be invalid.

I follow your way and it keep give out “Product is genuinely activated!” after few days i remove the license from dashboard. (suppose it would re-check server after a day),
Could any command I could check when it is validate on server, when it is validate by local data??

Can you share your new code

Here is the new code using 2.6.3 to build.

#define UNICODE
#include <stdio.h>
#include <stdlib.h>
#include “LexActivator.h”
#include <Winbase.h>

#if _WIN32
#if _WIN64
#pragma comment(lib,“x64/LexActivator”)
#else
#pragma comment(lib,“x86/LexActivator”)
#endif
#endif

int main()
{

int status;
TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = sizeof(computerName) / sizeof(computerName[0]);
GetComputerName(computerName, &size);




status = SetProductFile(L"Product.dat");
printf(" SetProductFile status:", status);
if(LA_OK != status) {
	printf("Error code: %d",status); 
	getchar();
	return status;
}
status = SetVersionGUID(L"xxxxx", LA_USER);
status = SetDayIntervalForServerCheck(1);
status = SetGracePeriodForNetworkError(1);

if(LA_OK != status) {
	printf(" Error code2: %d",status); 
	getchar();
	return status;
}


status = IsProductGenuine();
printf(" IsProductGenuine status:", status);
if(LA_OK == status) {
	printf(" Product is genuinely activated!22222");  

}
else if(LA_EXPIRED == status) {
	printf(" Product is genuinely activated, but license validity has expired!");  
}
else if(LA_GP_OVER == status) {
	printf(" Product is genuinely activated, but grace period is over!");  
}
else {

	status = SetProductKey(L"xxxxxx");
	
	if (LA_OK != status) {
		printf("Error code: %d", status);
		getchar();
		return status;
	}

	SetExtraActivationData(computerName);
	status = ActivateProduct();    // Ideally on a button click inside a dialog
	printf(" ActivateProduct status:", status);
	if (LA_OK == status) {
		printf("Product activated successfully!");
		
	}
	else {
		printf("Product activation failed: %d", status);
	}

	
	
}     
getchar();
return 0;

}

Please remove the ActivateProduct() code after your product activates.

What is the point to remove the ActivateProduct()?
Suppose after product activates, our program would not fall into that session anymore.

There is no such thing like session. You can create a command line switch lets’s say

-a and -pkey

and invoke ActivateProduct() function only when the two are present. So, in order to activate you will invoke your command line app as following:

myapp.exe -a -pkey=XXXX-XXXX-XXXX-XXXX

Sorry i am quiet confuse now, could you mind to send me a sample code that to show how the SetDayIntervalForServerCheck() and SetGracePeriodForNetworkError() work perfectly in C++ based on LexActivator C++ API sample code.

Thank you.

Hi There, I used another method to test if the program is sync with server again. As I added customField on Dashboard and changed the value after activated, the customField value keep update if license is valid on Dashboard.
And then I deactivate the license through dashboard. I changed the customField value again. After 48hours, the customField value remain the old and never update, so I guess the program is just checking the local data after it find the license is deactivate and fail into the grace period.

So my question is, what is the correct way to use SetDayIntervalForServerCheck()? now even I set the value to 1, and it seems did not kill the license validation after 24hrs.

Could you check it out on that? even I using the latest LexActivator v2.7.0.,

#define UNICODE
#include <stdio.h>
#include <stdlib.h>
#include
#include “LexActivator.h”
#include <Winbase.h>
#include
#include

#if _WIN32
#if _WIN64
#pragma comment(lib,“x64/LexActivator”)
#else
#pragma comment(lib,“x86/LexActivator”)
#endif
#endif

int main()
{

int status;
wchar_t PCName[256];
TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = sizeof(computerName) / sizeof(computerName[0]);
GetComputerName(computerName, &size);


TCHAR Username[1024];
DWORD Usize = sizeof(Username) / sizeof(Username[0]);
GetUserName(Username, &Usize);



status = SetProductFile(L"Product.dat");
printf(" SetProductFile status:", status);

status = SetVersionGUID(L"xxxx", LA_USER);
status = SetDayIntervalForServerCheck(1);
status = SetGracePeriodForNetworkError(1);

if(LA_OK != status) {
	printf(" Error code2: %d",status); 
}


status = IsProductGenuine();
printf(" IsProductGenuine status:", status);
if(LA_OK == status) {
	int PCName1 = GetCustomLicenseField(L"300", PCName, 256);
	std::wcout  <<"testing:" << PCName;
	printf(" Product is genuinely activated!");  

}else {

	status = SetProductKey(L"xxxxx");

	if (LA_OK != status) {
		printf("Error code: %d", status);
	}

	SetExtraActivationData(computerName);
	status = ActivateProduct();    // Ideally on a button click inside a dialog
	printf(" ActivateProduct status:", status);
	if (LA_OK == status) {
		printf("Product activated successfully!");

	}
	else {
		printf("Product activation failed: %d", status);
	}


}

if (LA_EXPIRED == status) {
	printf(" Product is genuinely activated, but license validity has expired!");
}
if (LA_GP_OVER == status) {
	printf(" Product is genuinely activated, but grace period is over!");
}



getchar();
return 0;

}

Hi,

Program always reads from the local data, when local data is synced after the server sync, next time it will give you the correct value.

Secondly, you should not deactivate the license from dashboard unless the key is to be used on other PC, If you want to block the key either revoke the key or delete the key from dashboard.

If you want to deactivate, deactivate it from client unless it’s not possible.