By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

Preventing the user from changing the system time

vdraceil
100+
P: 236
Is it possible to find whether the current system date is changed or not with VB6.0 code?All i want to do is to prohibit the user from changing the system time.How can i do that?
Jan 26 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 5K+
P: 8,434
Is it possible to find whether the current system date is changed or not with VB6.0 code?All i want to do is to prohibit the user from changing the system time.How can i do that?
I'd say that as long as the application is running, you could track a couple of things that might help. For instance, there is a"tick count" that indicates the number of times an internal clock has "ticked" since... um, either midnight, or system start-up, I forget which. You could keep track of that, and compare it with the current system time. If they suddenly get 'way out of synch, bingo!

You could also detect quite easily if the time goes backward, in which case it must have been altered. (Unless the user really is going backward in time, but that's probably outside the scope of this discussion). This could include recording the time when your program is closed, and checking the time hasn't gone backward at start-up.

Of course there are things one probably should keep in mind...
  1. If it's the user's PC, then who are you to tell them what they can't do do it?
  2. Windows does sometimes have delays (no, really!) so the fact that the time skips a bit between checks should not be taken as significant. In other words, if you have a timer set up to run every 30 seconds, and suddenly find that the time has changed 5 minutes instead, that might just mean the system was busy for a while.
  3. Windows may have been configured to automatically synchronise the system time with some server somewhere. Which could cause the time to unexpectedly shift in either "direction". You don't (I assume) want your software to suddenly stop and accuse the user of perfidy for no apparent reason.
  4. Two words... Daylight Saving.
  5. You probably should look into Windows "policies". I think Windows can be set up to prevent the user changing the time. (See point 1.)

P.S. Um... actually, I think there's probably a message Windows sends out to all running apps to notify them the system time was changed. So you might just watch that.
Jan 27 '08 #2

werks
100+
P: 220
tnx killer for the logic


Better Than Yesterday ^^
Jan 27 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.