You can store the first and last execution date in a file and also store a salted checksum of it. As @Timbo said, any decent hacker will get around this (as he would with practically any other method).
Like this, you can store something like this in a file anywhere (maybe in the register)
20090801:20090815:20090901
ca5579e3bacb7557b6ed22b5f553f9d5
being:
20090801 - the start date
20090815 - the last execution date
20090901 - the final date
ca5579e3bacb7557b6ed22b5f553f9d5 - the salted MD5 checksum
this way you can check the validness of the checksum using an algorithm like this
bool CheckExpiry()
{
string SecretSalt = "Y*##d3F!@g^hk";
string InitialDate = FetchInitialDate();
string LastExecutionDate = FetchLastExecutionDate();
string FinalDate = FetchFinalDate();
int Checksum = FetchChecksum();
string FinalString = InitialDate + ":" + SecretSalt + ":" + LastExecutionDate + ":" + FinalDate;
int InternalCheckSum = md5sum( FinalString );
return InternalCheckSum == CheckSum;
}
of course you can use SHA-1 or any other digest algorithm you like more. Just make sure you use a not easily guessable SecretSalt
.
And you can check the LastExecutionDate
against the current date to check if the date was changed backwards.