Autor Beitrag
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 19.11.04 16:36 
Hi,

ich will von Windows die WMEndSession erhalten, wenn es runterfährt, 0 zurückgeben und das Prog beenden. Nur irgendwie bleibt manchmal das Prog offen, manchmal häng Win. Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.WMEndSession(var Msg: TMessage);
begin
  Msg.Result := 0;
  inherited;
  Halt;
end;


Was mach ich falsch?

AXMD
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 19.11.04 20:39 
Siehe MSDN\PSDK unter Suche im MSDN WM_QUERYENDSESSION bzw. Suche im MSDN WM_ENDSESSION

Weiterhin sollte Inherited immer zu erst aufgerufen werden.

Weiterhin solltest du Application.Terminate anstatt Halt verwenden. Halt ist kein guter Programmierstil!

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
AXMD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Sa 20.11.04 09:11 
Danke für die Links.

Zitat:
If any application returns zero, the session is not ended.


Die Frage ist nur: was soll das Programm dann zurückgeben?

Folgender Code funktioniert nicht

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.WMEndSession(var Msg: TMessage);
begin
  inherited;
  end_flag := true;
  Application.Terminate;
end;


AXMD
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 20.11.04 11:58 
Irgenddwas ungleich null eben. ;)
AXMD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Sa 20.11.04 12:03 
Muss ich das angeben oder macht das bereits der inherited-Teil?

AXMD
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 20.11.04 12:04 
Ich würde es angeben. Desweiteren wäre WM_QUERYENDSESSION besser, da bei WM_ENDSESSION schon alles gelaufen ist. Steht doch auch so im PSDK.
AXMD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Sa 20.11.04 12:12 
Sorry, hatte vergessen zu erwähnen, dass ich WM_QUERYENDSESSION verwende; hab die Funktion nur verkürzt geschrieben, weil ich mir Schreibarbeit ersparen wollte ^^

AXMD