Friday, April 29, 2011

Is there an API event for when person changes clock on Windows?

I was wondering if there's some sort of system event that gets fired every time a user changes the time in Windows. I know there's a way to enable this in Windows' EventLog, but I was looking for a way to respond to this event programatically (like using the Windows API).

From stackoverflow
  • A WM_TIMECHANGE message is sent whenever there is a change in the system time

    JaredPar : +1, correct answer to one of the possible intents of an ambiguous question
    enriquein : Agreed, I'm sorry for the ambiguity.
  • I'm not sure from your question if you're working in managed or native code. But if you're working in managed code you can use the TimeChanged event on the SystemEvents class.

    Microsoft.Win32.SystemEvents.TimeChanged

    enriquein : My apologies for not being completely clear. But yes, I will be running this on a managed environment so your answer is what I was looking for.
    Stuart Dunkeld : +1 back, it's only fair!
  • WM_TIMECHANGE exists since windows 3.0, for 19 years !
    Incredible to ask a such thing nowadays ...

0 comments:

Post a Comment