unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
protected
procedure OnWindowsEixt(var Msg:TWMQUERYENDSESSION);message WM_QUERYENDSESSION;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.OnWindowsEixt(var Msg:TWMQUERYENDSESSION);
var
f:TextFile;
FileHandle:Integer;
begin
//将退出时间记录在C:/WindowsCloseTime.txt文件中
FileHandle := FileCreate('C:/WindowsCloseTime.txt');
FileClose(FileHandle);
AssignFile(f,'C:/WindowsCloseTime.txt');
Rewrite(f);
Write(f,TimeToStr(Now));
CloseFile(f);
//
Msg.Result := 1;
end;
end.