Question

I have a windows application and I want any event when user changes the time of that system on which that windows application is opened or running.

How can I get that changed time or specific time or any event of system change of time/date?

Was it helpful?

Solution

You can subscribe to SystemEvents.TimeChanged event.

To subscribe to above event, do the following:

1.Create TimeChanged EventHander.

    private void time_Changed(object sender, EventArgs e)
    {
       MessageBox.Show("Time Changed");  
    }

2.Add above event handler to SystemEvents.TimeChanged event.

 SystemEvents.TimeChanged += time_Changed;

OTHER TIPS

...or any event of system change of time/date? SystemEvents.TimeChanged will only trigger "when the user changes the time on the system clock".

System time changes may also occur due to system time adjustments, being initiated by the system or the user. You may use the GetSystemTimeAdjustment function to capture such system time adjustments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top