9

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.

user7116
  • 63,008
  • 17
  • 141
  • 172
Oren
  • 91
  • 1
  • 2

2 Answers2

2

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.

Petko Petkov
  • 730
  • 3
  • 7
  • Thanks! But the SystemEventsClass - TimeChanged Occurs only "when the user changes the time on the system clock". is there a way to detect automatic time changes done due to daylight savings time? The EventID in EventLogEntry class is unfortunately obsolete (http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlogentry.eventid.aspx) – Oren May 29 '11 at 17:43
0

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.

ScottTx
  • 1,483
  • 8
  • 12
  • Thanks Scott I'm not sure how one can find out of a manual time change or if the system automatically changed the time due to Daylight Saving during the time the application was offline according to what you suggest. – Oren May 29 '11 at 17:51