Trial activation not workingSolved

Hello,I am sure I am doing something simple wrong but do not know what it is. In my code below I believe I am handlign the trial correctly but instead of allowing the trial period it indicates the trial is over on the second entry (even if same day) and asks for code. Thank you for any help in pointing me to what is wrong.

@// LimeLM for licensingbool checkLicense(QSplashScreen *splashp){ HRESULT hr; GENUINE_OPTIONS opts; opts.nLength = sizeof(GENUINE_OPTIONS);

// How often to verify with the LimeLM servers (90 days) opts.nDaysBetweenChecks = 0; // setting to zero should allow for immediate effect if revoke a license, but doesn't always seem to work

// The grace period if TurboActivate couldn't connect to the servers. After the grace period is over IsGenuinEx() will return TA_FAIL instead of TA_E_INET or TA_E_INET_DELAYED opts.nGraceDaysOnInetErr = 14;

// In this example we won't show an error if the activation was done offline by passing the TA_SKIP_OFFLINE flag opts.flags = TA_SKIP_OFFLINE;

hr = IsGenuineEx(TA_GUID, &opts); printf("hr=%d\n", hr); if (hr == TA_OK || hr == TA_E_FEATURES_CHANGED || hr == TA_E_INET || hr == TA_E_INET_DELAYED) { TCHAR * featureValue; //printf("YourApp is activated and genuine! Enable any app features now.\n"); if (hr == TA_E_INET || hr == TA_E_INET_DELAYED) { // TODO: show a warning to your user that this time (or the last time) // the IsGenuineEx() failed to connect to the LimeLM servers. //printf("YourApp is activated, but it failed to verify the activation with the LimeLM servers. You can still use the app for the duration of the grace period.\n"); QString msgText = QSplashScreen::tr("\n\n\n\n\n\n CAP is temporarily activated, but it failed to verify the activation online. Contact Elucid if this notification persists."); splashp->showMessage(msgText, Qt::AlignLeft, Qt::lightGray); splashp->repaint(); // ensure progress is shown qApp->processEvents(); }

// if this app is activated then you can get a feature value (completely optional) // See: http://wyday.com/limelm/help/license-features/ /* hr = GetFeatureValue(_T("your feature value"), 0, 0); featureValue = (TCHAR *)malloc(hr * sizeof(TCHAR)); hr = GetFeatureValue(_T("your feature value"), featureValue, hr); if (hr == TA_OK) {#ifdef _WIN32 wprintf(L"Feature value: %s\n", featureValue);#else printf("Feature value: %s\n", featureValue);#endif } else printf("Getting feature failed: %d\n", hr); free(featureValue); */ } else if (hr == TA_E_REVOKED) { QString msgText = QSplashScreen::tr("\n\n\n\n\n\n Your product key can not be authorized.\n Contact Elucid if you consider this to be in error."); splashp->showMessage(msgText, Qt::AlignLeft, Qt::lightGray); splashp->repaint(); // ensure progress is shown qApp->processEvents(); QThread::msleep(5000); return false; } else { // not activated or genuine but not revoked either - so give trial uint32_t trialDays = 30;

// Look in TurboActivate.h for what the error codes mean.

// Start or re-validate the trial if it has already started. This need to be called at least once before you can use any other trial functions. hr = UseTrial(TA_USER);

if (hr == TA_OK) { // Get the number of trial days remaining. hr = TrialDaysRemaining(TA_GUID, &trialDays);

if (hr == TA_OK) { QThread::msleep(1000); if (trialDays > 0) { //printf("Trial days remaining: %d\n", trialDays); QString msgText = QSplashScreen::tr("\n\n\n\n\n\n ...activating CAP on a trial basis ("); msgText.append(QString::number(trialDays)); msgText.append(" trial days remaining),"); splashp->showMessage(msgText, Qt::AlignLeft, Qt::lightGray); splashp->repaint(); // ensure progress is shown qApp->processEvents(); QThread::msleep(2000); return true; } else { QString msgText = QSplashScreen::tr("\n\n\n\n\n\n CAP trial period ended."); splashp->showMessage(msgText, Qt::AlignLeft, Qt::lightGray); splashp->repaint(); // ensure progress is shown qApp->processEvents(); } } else { printf("Failed to get the trial days remaining: hr = %d\n", hr); return false; } } else { printf("Failed to UseTrial: hr = %d\n", hr); return false; }

// prompt for a product key (given that it's not present) QThread::msleep(5000); QString msgText = QSplashScreen::tr("\n\n\n\n\n\n CAP is not currently activated. Please enter the product code that was\n contained in the email Elucid sent to you."); splashp->showMessage(msgText, Qt::AlignLeft, Qt::lightGray); splashp->repaint(); // ensure progress is shown qApp->processEvents(); QThread::msleep(5000); splashp->hide(); splashp->repaint(); // ensure progress is shown qApp->processEvents(); printf("Please enter product key: "); #if defined _MSC_VER wchar_t productKey[100]; wscanf(L"%ls", productKey); #else char productKey[100]; scanf("%s", productKey); #endif splashp->show();

//Example: here we're just hard-coding the product key to show how you // save the product key and try to activation // Also note we're using the TA_SYSTEM flag. This means the activation will be system-wide. // However calling using the TA_SYSTEM flag (the first time only) requires system-admin privileges. // If your app will never have system admin privileges then you can use the TA_USER flag. //hr = CheckAndSavePKey(_T("RH72-6SNS-IHE7-UJ57-2UVU-24H2-4ATA"), TA_SYSTEM); #if defined _MSC_VER hr = CheckAndSavePKey(productKey, TA_USER); #else hr = CheckAndSavePKey(_T(productKey), TA_USER); #endif if (hr == TA_OK) { printf("Product key saved successfully.\n"); QString msgText = QSplashScreen::tr("\n\n\n\n\n\n Product key saved successfully"); splashp->showMessage(msgText, Qt::AlignLeft, Qt::lightGray); splashp->repaint(); // ensure progress is shown qApp->processEvents();

// try to activate hr = Activate();

if (hr == TA_OK) printf("Activated successfully\n"); else { //printf("Activation failed: hr = %d\n", hr); QString msgText = QSplashScreen::tr("\n\n\n\n\n\n CAP could not activate: error code="); msgText.append(QString::number(hr)); splashp->showMessage(msgText, Qt::AlignLeft, Qt::lightGray); splashp->repaint(); // ensure progress is shown qApp->processEvents(); return false; } } else { //printf("Product key failed to save: hr = %d\n", hr); QString msgText = QSplashScreen::tr("\n\n\n\n\n\n Product key failed to save: error code="); msgText.append(QString::number(hr)); splashp->showMessage(msgText, Qt::AlignLeft, Qt::lightGray); splashp->repaint(); // ensure progress is shown qApp->processEvents(); return false; } }

printf("Product key based activation successful.\n"); return true;}@

Please your reply and help on this, coding seems correct yet trials are not allowed by system.

Hey Andy,

Sorry for the delayed response, the last couple of days have been an all-out push to get TurboActivate 4.0 out.

We need more information to help you, though. What exactly is going wrong? Are you activated and TurboActivate is saying you're not activated?

Also, don't use "nDaysBetweenChecks = 0". That's a terrible idea -- it punishes legit customers. The minimum that value should be is "1". We recommend 90, but even 7 days is a reasonable value.

But I need more information about exactly what error you're getting.

Thank you; as it happens, I did change nDaysBetweenChecks... after posting, I spotted that and thank you for spotting it too. This didn't change the issue I am having, but better to have it a reasonable value.

The problem I am having is that trialDays is coming back as a zero, even the very fist day of a trial. We have had to issue product keys as a workaround for these customers just to allow them to use the software. I would think that something more major was wrong, but since the product key feature is working, and the return "hr" values all seem to make sense, I cannot see the problem.

More specifically, here is the code at which trialDays is 0, even though trial length is set to 30 days on the limelm site for this product:// Get the number of trial days remaining.hr = TrialDaysRemaining(TA_GUID, &trialDays);

if (hr == TA_OK) {QThread::msleep(1000);if (trialDays > 0) {

Well, first of all, make sure you set the number of trial days remaining to a non-zero value in LimeLM, and then re-download the TurboActivate.dat file, and replace the one you have included with your app.

Next, make sure that UseTrial() is returning TA_OK.

Next, make sure you hadn't started the trial before -- even calling TurboActivate.exe starts the trial. Replacing the TurboActivate.dat file doesn't "reset" the trial. If you want to extend the trial, see here: https://wyday.com/limelm/help/trials/#extensions

Thank you, replacing the TurboActivate.dat is what fixed it. In prior testing I had set the trial days to 0 (in order to test the behavior at the end of a trial period without waiting for 30 days) and had not understood that when I changed it back to 30 days on the site that this wasn't effective until making a new .dat file. But your reply helped me see that, and now it works, so thank you.

Andy