October 08, 2008

Tips 8


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.

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.

0 comments:

Post a Comment

 

Copyright 2008 All Rights Reserved | Blogger Template by Computer Science and Computer Tips