Solved

detect a date change

Posted on 2000-03-14
8
207 Views
Last Modified: 2012-06-27
How do you detect when the system date has changed?
0
Comment
Question by:millenisys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

751 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