Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Art des Shutdown herausfinden (https://www.delphipraxis.net/50565-art-des-shutdown-herausfinden.html)

Zacherl 27. Jul 2005 18:13


Art des Shutdown herausfinden
 
Hallo,
in meinem Programm fange ich das Herunterfahren von Windows mit der WM_QueryEndSession ab. Wie kann ich aber feststellen, ob Windows "herunterfährt, neu startet" oder sich jamand abmeldet? Sieht man das am lParam oder wParam der Message?

Florian

marabu 27. Jul 2005 18:19

Re: Art des Shutdown herausfinden
 
Gut geraten...

Zitat:

Zitat von Microsoft
lParam
If this parameter includes ENDSESSION_LOGOFF, the user is logging off. (Note that this parameter is a bit mask. To test for this value, use a bit-wise operation; do not test for equality.)
If this parameter is zero, the system is shutting down.

marabu

toms 27. Jul 2005 23:17

Re: Art des Shutdown herausfinden
 
aus einer google paq:

Delphi-Quellcode:
type
  TForm1 = class(TForm)
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    procedure WMQueryEndSession(var Msg: TWMQueryEndSession); message
WM_QUERYENDSESSION;
    procedure WMEndSession(var Msg: TWMEndSession); message
WM_ENDSESSION;
  public
  end;


procedure TForm1.WMEndSession(var Msg: TWMEndSession);
var
  S1, S2: String;
begin
  case Msg.Unused of
    Integer(ENDSESSION_LOGOFF): S1 := 'Benutzer abmelden';
    else S1 := 'Windows beenden';
  end;
  if Msg.EndSession
  then S2 := ' wird jetzt durchgeführt'
  else S2 := ' abgebrochen';
  ShowMessage(S1 + S2);
  inherited;
end;


procedure TForm1.WMQueryEndSession(var Msg: TWMQueryEndSession);
var
  S: String;
begin
  case Msg.Unused of
    Integer(ENDSESSION_LOGOFF): S := 'Benutzer abmelden';
    else S := 'Windows beenden';
  end;
  if MessageDlg(S+' okay?', mtConfirmation, [mbYes, mbNo], 0) = mrYes
  then Msg.Result := 1 
  else Msg.Result := 0;
end;


procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose:
Boolean);
begin
  CanClose := MessageDlg('Anwendung beenden okay?',
    mtConfirmation, [mbYes, mbNo], 0) = mrYes;
end;


procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ShowMessage('Anwendung wird jetzt beendet');
end;

Zacherl 29. Jul 2005 10:32

Re: Art des Shutdown herausfinden
 
Danke erst mal!
Nur wird hier nur zwischen Abmelden und Beenden unterschieden. Kann man auch herausfinden, ob der Computer Neu gestartet wird?

Florian

himitsu 29. Jul 2005 10:49

Re: Art des Shutdown herausfinden
 
Zitat:

Zitat von marabu
Zitat:

Zitat von Microsoft
lParam
If this parameter includes ENDSESSION_LOGOFF, the user is logging off. (Note that this parameter is a bit mask. To test for this value, use a bit-wise operation; do not test for equality.)
If this parameter is zero, the system is shutting down.


Fahre deinen Computer doch einfach mal in den verschiedenen Modies runter und schau dir dabei die gesetzten Bits von lParam an ...


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:43 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz