adopilot
adopilot

Reputation: 4500

Subscribe to event of changing time on local system

Is there a way to my C# winforms application knows when Date and time settings has changed on local computer.

Upvotes: 0

Views: 1788

Answers (2)

djdd87
djdd87

Reputation: 68476

Yes, you want to take a look at SystemEvents.TimeChanged.

Microsoft.Win32.SystemEvents.TimeChanged += 
    new EventHandler(SystemEvents_TimeChanged);

void SystemEvents_TimeChanged(object sender, EventArgs e)
{
    // The system time was changed
}

From the documentation:

Occurs when the user changes the time on the system clock.

Upvotes: 6

Fredrik Mörk
Fredrik Mörk

Reputation: 158309

I think SystemEvents.TimeChanged is what you are looking for.

Upvotes: 2

Related Questions