Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Delphi] Comparing CurrentDate/LicensekeyDate

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Sun May 04, 2008 6:37 pm    Post subject: [Delphi] Comparing CurrentDate/LicensekeyDate Reply with quote

I want to come up with a good algoritm for comparing the current date and the date within the "license key".

It's late right now and it's 05.05.2008.

Here what i've tried so far:

Try one:
Quote:
if (day>=21) and (month>=3) and (year>=2008) then showmessage('License expired!') else showmessage('License not expired!');

This returns:
Quote:
License not expired! Shocked

It seems that i messed it up somewhere with the "and" and it doesn't retur the correct value.

I can't think of a good algoritm either... i am sleepy and i thinked of a "something" which i realised that is stupid but here it is:

Quote:
{if (year>=2009) then showmessage ('License expired! Smile') else
begin
if (month>=1) then showmessage ('License expired! Smile') else
begin
if (day>=5) then showmessage('License expired! Smile') else showmessage('License not expired! Sad');
end;
end;}


first line returns false >> skip showmessage and continue
second line returns true >> show message that is expired, BUT GOD .... It's A KEY UNTILL 2009 year....... Rolling Eyes

Anyway can someone show me a hint about fixing that problem or helping at building that algoritm the right way.... so...

By the way i looked in the net for some tips and tricks about this and i happend to find that: http://delphi.about.com/library/rtl/blrtlCompareDate.htm which didn't really help me.

And here is my current code and declarations:

Code:
procedure TForm1.Button2Click(Sender: TObject);
var
year,month,day: word;
begin
decodedate(now,year,month,day);
{if (year>=2009) then showmessage ('License expired! :)') else
begin
if (month>=1) then showmessage ('License expired! :)') else
begin
if (day>=5) then showmessage('License expired! :)') else showmessage('License not expired! :(');
end;
end;}
if (day>=21) and (month>=3) and (year>=2008) then showmessage('License expired! :)') else showmessage('License not expired! :(');
end;
end.

_________________

Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sun May 04, 2008 6:43 pm    Post subject: Reply with quote

Just reverse it.

if(year<=2009) license ok
else if(month<=1) license ok
else if(day <=5)license ok
else license bad

EDIT:
that wouldn't work for some stuff

if(year < 2009) license ok
else if(year > 2009) license bad
else if(month < 1) license ok
else if(month > 1) license bad
else if(day <= 5) license ok
else license bad

_________________
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Sun May 04, 2008 7:02 pm    Post subject: Reply with quote

HalfPrime, your method doesn't work because:

Quote:
if (year<2002) then showmessage ('License is ok Smile') else
begin
if (month<6) then showmessage ('License is ok Smile') else
begin
if (day<22) then showmessage('License is ok Smile') else showmessage('License is bad! Sad');
end;
end;


Returns:

Quote:
('License is ok Smile')


Edit:

Haha nice edit of your post. Laughing

Edit2:

I will go to sleep i can't think like that. I hope in the morning i will have a fresh mind. I wish you good luck to all of you. Wink

_________________

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites