Subscribe to event of changing time on local system

↘锁芯ラ 提交于 2019-12-11 16:33:47

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/3787299/subscribe-to-event-of-changing-time-on-local-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!