开发者

Detect manual time change and daylight savings time events in windows events log

开发者 https://www.devze.com 2023-03-08 23:51 出处:网络
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.

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 s开发者_如何学运维omething that will identify an event uniquely as time change event.


You can use the SystemEventsClass to respond to a time change event during runtime.

As for the event log you can try digging some info about Event ID 520 in the windows security log, this post has some info about it.


I think a better solution would be to save the current date/time/timezone/dst settings the first time your app starts. Then check them on every subsequent app restart. In conjunction with the SystemEvents class to catch runtime changed this would be infinitely better than trying to parse eventlog entries - which can be purged / cleared.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号