Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

detect a date change

Posted on 2000-03-14
8
Medium Priority
?
209 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 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 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