How to detect system time change
If the user changes the system time either with Date and Time properties dialog box or using command line, we can detect this by catching WM_TIMECHANGE system message. Here is how.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) private { Private declarations } procedure WMTimeChange(var Msg: TMessage); message WM_TIMECHANGE; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.WMTimeChange(var Msg: TMessage); begin ShowMessage('System time was just changed!'); end; end. |