C#在Windows事件日志中检测手动时间更改和夏令时事件 [英] C# Detect manual time change and daylight savings time events in windows events log

查看:305
本文介绍了C#在Windows事件日志中检测手动时间更改和夏令时事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在C#应用程序运行时中检测到系统时间和日期的手动更改以及夏时制的自动更改.
此外,我正在寻找一种方法来检测在用户启动应用程序时应用程序处于脱机状态期间发生的这些更改.
在此页面http://support.microsoft.com/kb/815314中,提供了有关如何扫描事件日志的说明,但是我找不到能将事件唯一标识为时间更改事件的内容.

预先感谢您的帮助,
Oren

Hi,

I would like to detect during my C# application run-time a manual change of the system time and date and automatic daylight savings time change.
Moreover I am looking for a way to detect these changes that happened during the time the application was offline when the user launched the application.
In this page http://support.microsoft.com/kb/815314 there is an explanation how to scan the events log but I couldn''t find something that will identify an event uniquely as time change event.

Thanks in advance for your help,
Oren

推荐答案

有一个 SystemEvents.TimeChanged [ ^ ]事件,当用户更改系统时钟上的时间时触发.

程序未运行时,可以将值存储在DateTime.Now.IsDaylightSavingTime中,并在下次启动时使用该值进行比较.
There is a SystemEvents.TimeChanged[^] event that is triggered when the user changes the time on the system clock.

When the program is not running, you can store the value in DateTime.Now.IsDaylightSavingTime and use this to compare at next startup.


这篇关于C#在Windows事件日志中检测手动时间更改和夏令时事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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