Solved

detect a date change

Posted on 2000-03-14
8
203 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now