防止修改日期和时间 [英] Prevent to amendment Date and Time

查看:170
本文介绍了防止修改日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的程序执行过程中如何防止用户修改操作系统的日期和时间

请通过代码给我一个例子

感谢您的配合

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

推荐答案

您不能阻止用户更改自己计算机时钟的日期/时间.

您可以*跟踪上一次执行您的应用程序的时间,有几种方法可以做到.您可以:

-将日期/时间存储在注册表中.
-将日期/时间存储在文件中
-将日期/时间存储在可执行文件本身中
-您可以更改数据文件的日期/时间
-您可以更改可执行文件本身的日期/时间

继续并进行编码.
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.


您还可以尝试使用基于Internet的块来验证时间,但这会增加一系列可能不值得的问题.

如果只是更改了应用程序运行时的时间,则可以按固定的时间间隔(例如,每分钟)轮询一次时间,并确保它一次偏移的时间不超过2-3分钟(您可以每次如果线程饿了,则必须这样做).这将是黑客,但这是另一种方法.
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.


这应该由管理员而不是您的软件应用于用户帐户(这是我的系统/网络-您不确定我可以做什么,不能做什么!).默认情况下,受限帐户无法更改系统日期和时间.

如果出于某种原因要检查实际日期和时间而不是计算机,请使用SNTP.有一些关于CP的文章,如果您搜索的话,其中有一篇来自我.
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.


这篇关于防止修改日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆