Re: Get last boot-date/time in Windows
- From: "gandalf" <gandalf@xxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 22 Aug 2005 00:47:32 +0100
"Norbert Roth" <surfyxx@xxxxxxxxxxxxxx> wrote in message
news:3mrdp4F186g2bU1@xxxxxxxxxxxxxxxxx
> is there a way to check the original boot date/time, if the operating
> system
> time-date has been changed in the Windows Date/time control dialog without
> reboot?
>
> (to check, if a user cheats a trial-version by setting the os-time back,
> without
> rebooting)
>
> Thanks for hints
>
-------------
It all depends on the skill of the cheat really. I presume you encrypt and
log somewhere in the registry the date of installation and your programme
checks off against that. It's also a good idea to log occasionally when your
programme is running and check that a date/time isn't earlier than one
already logged. If your programme simply tells folk it's trial period has
expired and closes down without writing something in the registry (or
somewhere else safe from prying eyes) to let you know it has already
expired, then you are leaving the door open to fiddling with the date/time.
You can still out-fox them though using Atoms. (Magical obscure Windows
toys)
When your programme determines that it has expired then (as well as whatever
else you do) you make it do this:
//
GlobalAddAtom('Make up some really obscure text that no one else will think
of');
//
The text can be whatever you want but make it obscure enough so that you can
be reasonably sure it is unique.
You also need to make sure that each time your programme starts you do this:
//
procedure TForm2.FormActivate(Sender: TObject);
begin
if GlobalFindAtom('Make up some really obscure text that no one else
will think of')<>0 then
begin
ShowMessage('Your trial period has expired');
Close;
end;
end;
//
The text in both instances must be exactly the same. GlobalAddAtom creates
an Atom with your text in it and GlobalFindAtom checks to see if an Atom
exists with that content. Atoms exist from the time they are created until
Widows is reset, so no one (unless they know your obscure text and have a
working understanding of Atoms..lol) is ever going to make your programme
run again without a full reset.
You can get a little fancier, especially if you know someone is messing
about with the clock.
Atoms not only contain stuff they have an ID number (pointer), so it's
possible to put something in one, a date and time for instance, and then
check it later by calling it up using the pointer. This way you need to know
what the Atom ID is, not exactly what's in it, to access it.
You could put the Date/Time in one, every time you startup succesfully, like
this:
//
procedure TForm2.Button3Click(Sender: TObject);
var AtomInt: Integer;
Buffer: PChar;
ReturnStr: String;
begin
Buffer:=StrAlloc(50);
Edit1.Text:=DateTimetoStr(now);
AtomInt := GlobalAddAtom(PChar(Edit1.Text)); // This creates the Atom
and gives you it's pointer.(hide it somewhere safe)
GlobalGetAtomName(AtomInt,Buffer,50); // This is just calling it up so
we can see what's in it
ReturnStr:=StrPas(Buffer);
Edit2.Text:=IntToStr(AtomInt);
Edit3.Text:=ReturnStr;
StrDispose(Buffer);
end;
//
I used the Edit boxes so I could check what I was doing, they serve no other
purpose.
Now when your programme wakes up you can get it check like this:
//
procedure TForm2.Button4Click(Sender: TObject);
var AtomInt: Integer;
Buffer: PChar;
ReturnStr: String;
begin
Buffer:=StrAlloc(50);
AtomInt := 49217; // Get the pointer back from where ever you hid it
(49217 was just the Atom my machine created)
GlobalGetAtomName(AtomInt,Buffer,50);
ReturnStr:=StrPas(Buffer);
Edit4.Text:=ReturnStr;
if StrToDateTime(ReturnStr)>(now) then
begin
ShowMessage('That''s pitiful!'#13#10
+'My kid sister could do better than that'#13#10#13#10
+'Anyway - It''s still expired!!');
Close;
end;
StrDispose(Buffer);
end;
//
I only recently stumbled across Atoms so I'm no expert by any means but the
stuff above works. I've just being playing about making a little programme
to test it all out, but you get the idea. I reckon the registry is the best
place for hiding stuff but it won't keep everyone at bay so maybe a mix of
both Atoms and the registry would drive them nuts. They change something,
you access an Atom and change it back - hours of fun..
(I'll probably be up half the night now spying on all the other Atoms - I
wonder what's in them all.....)
HTH
John
.
- Follow-Ups:
- Re: Get last boot-date/time in Windows
- From: Norbert Roth
- Re: Get last boot-date/time in Windows
- References:
- Get last boot-date/time in Windows
- From: Norbert Roth
- Get last boot-date/time in Windows
- Prev by Date: Re: PrintDialog question
- Next by Date: Re: Wondows system sound
- Previous by thread: Re: Get last boot-date/time in Windows
- Next by thread: Re: Get last boot-date/time in Windows
- Index(es):