Mega Code Archive

 
Categories / Delphi / System
 

Detecting if the system time has been changed

Title: Detecting if the system time has been changed Question: Is it possible to detect if the system time has been changed by another application? Answer: The following example demonstrates trapping the WM_TIMECHANGE message. Note: Applications that change the system time should broadcast a WM_TIMECHANGE message to all top level windows. type TForm1 = class(TForm) private { Private declarations } procedure WMTIMECHANGE(var Message: TWMTIMECHANGE); message WM_TIMECHANGE; public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.WMTIMECHANGE(var Message: TWMTIMECHANGE); begin Form1.Caption := 'Time Changed'; end;