Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to prevent the user from the amendment date and time of the operating system during the implementation of my program

and please give me an example by code

thank you for your cooperation
Posted
Updated 7-Jun-10 11:28am
v2

You can't keep the user from changing the date/time of his own computer's clock.

You *can* keep track of the last time your application was last executed, and there are several ways to do it. You could:

- store the date/time in the registry.
- store the date/time in a file
- store the date/time in the executable itself
- you could change the date/time of a data file
- you could change the date/time of the executable itself

Go forth and code.
 
Share this answer
 
You could also try using an internet based block to verify the time, but that adds a whole set of issues that are probably not worth it.

If its just changing the time while the application is running, you could just poll the time at regular intervals (say every minute) and make sure that it hasn't deviated by anything more than say 2-3 minutes at a time (you'd have to do this in case the thread is starved). It'd be a hack, but that'd be another way to do it.
 
Share this answer
 
This is something that should be applied to user acounts by an administrator, not by your software (It's my system/network - you do not decide what I can and can't do!). By default, limited acounts cannot change the system date and time.

If you want to check the real date and time rather than the machine's for some reason, then you should use SNTP. There are some articles on CP including one from me if you search.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900