Solved

detect a date change

Posted on 2000-03-14
8
206 Views
Last Modified: 2012-06-27
How do you detect when the system date has changed?
0
Comment
Question by:millenisys
8 Comments
 
LVL 2

Expert Comment

by:Tchalkov
ID: 2616183
you can periodically compare system date with a global variable which contains previous date
0
 
LVL 14

Accepted Solution

by:
mcrider earned 100 total points
ID: 2616185
Do you mean something like someone changing the date backwards to get around a license??

If so, before you end your program, do this:

   SaveSetting "MyApp", "Startup", "Time", CStr(Now)


Then when you start your program do this:


Dim lDate As Date

If Not GetSetting("MyApp", "Startup", "Time", "0") = "0" Then
    lDate = GetSetting("MyApp", "Startup", "Time", "0")
    If DateDiff("s", lDate, Now) < 0 Then
        MsgBox "You have moved the date back!"
    End If
End If



Cheers!®©
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2616231
Windows sends the WM_TIMECHANGE message whenever the time or date is changed.  VB can catch this message if you subclass your form to intercept windows messages.  An example of how to do this is in this MS article:

"HOWTO: Build a Windows Message Handler with AddressOf in VB"

http://support.microsoft.com/support/kb/articles/q170/5/70.ASP

The article uses the WM_RBUTTONUP message as an example, but you will replace it with
Public Const WM_TIMECHANGE = &H1E

Note: If you use subclassing, do not pause the code or add breakpoints or VB will crash in the IDE.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Expert Comment

by:vindevogel
ID: 2616250
On the fly ??

Make a timer, interval = 1000

Sub Timer1_Timer
   Static vLastTime as single

   If Abs(vLastTime - Timer) > 1 Then
      MsgBox "You're messing with the time"
   End If
End Sub

Keep this program running, of course.

If you want to do it without running a program, or detecting it afterwards ... Then I don't know.
0
 
LVL 1

Expert Comment

by:ndb
ID: 2616395
Comment for mcrider:
Your code should do perfectly.
But you better replace MyApp with a string that can't be related with your program because it is one of the first places where hackers will look for the timestamp.
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2616467
ndb,

<VBG> actually it was just an example... I store all of my keys and values in the registry as encrypted string... Can't read them, Got not clue what they do... <G>


Cheers!®©
0
 

Author Comment

by:millenisys
ID: 2616567
Thanks for all your help, I was hoping that NT (or 95/98) kept a setting in the registry.
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2616734
Thanks for the points, glad I could help!


Cheers!®©
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question