Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#7

AW: Windows wurde doch nicht heruntergefahren und ich merke davon nichts

  Alt 4. Dez 2015, 16:45
Folgender Code ist für WIN8.1 völlig uninteressant - oder ist da etwas falsch?
Wie müsste er aussehen, um irgendeine Reaktion auszulösen?

Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private-Deklarationen }
    procedure WMQueryEndSession(var Msg: TWMQueryEndSession);
      message WM_QUERYENDSESSION;
    procedure WMEndSession(var Msg: TWMEndSession);
      message WM_ENDSESSION;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMQueryEndSession(var Msg: TWMQueryEndSession);
begin
  if MessageDlg('Close Windows ?', mtConfirmation, [mbYes,mbNo], 0) = mrNo then
    Msg.Result := 0
  else
    Msg.Result := 1 ;
end;

procedure TForm1.WMEndSession(var Msg: TWMEndSession);
begin
  if Msg.EndSession = True then
    ShowMessage('Windows is shutting down ' + #10#13 + 'at ' + FormatDateTime('c', Now));
  inherited;
end;

end.
  Mit Zitat antworten Zitat