Hi,
I'm having an issue with the IsDateValid function. I created a custom date field called expire_date, and put a date in the future when the license should expire. When I run my function, it does what it is supposed to, in that it returns 0 when the expiration date is in the future, and 1 when the date is already passed. However, when the date is valid, calling print_ta_error does not return TA_OK according to the values given in the documentation, but rather it returns "Unknown". Grateful if you could take a look at the code and see if the problem is on my end - I don't want to risk there being some issue that might cause problems later on.
hr = GetFeatureValue(_T("expire_date"), 0, 0); TCHAR * featureValue; featureValue = (TCHAR *)malloc(hr * sizeof(TCHAR)); hr = GetFeatureValue(_T("expire_date"), featureValue, hr);
if (hr == TA_OK) { if (strcmp(featureValue, "1970-01-01 00:00:00") == 0) { //this special date means the license is permanent, so ignore expiry date printf("Permanent License is installed. "); } else { printf("License Expiry Date: %s\n", featureValue); char s[21]; size_t i; struct tm tim; time_t now; now = time(NULL); tim = *(localtime(&now)); i = strftime(s,21,"%Y-%m-%d %H:%M:%S\n",&tim); printf("Current Date: %s\n", s); hr = IsDateValid(_T(featureValue), TA_HAS_NOT_EXPIRED); print_ta_error(hr, "Date check result: "); }
} else printf("Getting feature failed: %d\n", hr);
free(featureValue); }