No entiendo bien en qué forma planeas usar el Msg.Source pero haciendo algunas pruebas me parece que Delphi tiene un pequeño
bug. La declaración de TWMQueryEndSession es:
Código Delphi
[-]
TWMQueryEndSession = packed record
Msg: Cardinal;
Source: Longint;
Unused: Longint;
Result: Longint;
end;
pero la documentación en el SDK de Windows dice:
Cita:
wParam
This parameter is reserved for future use.
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 or restarting (it is not possible to determine which event is occurring).
|
es decir, según yo entiendo, la declaración en Delphi está alrevés y debería ser:
Código Delphi
[-]
TWMQueryEndSession = packed record
Msg: Cardinal;
Unused: Longint;
Source: Longint;
Result: Longint;
end;
Aunque no lo puedo asegurar, parece ser corroborado por esta prueba:
Código Delphi
[-]
procedure TForm1.WMQueryEndSession(var Msg: TWMQueryEndSession);
begin
inherited;
if Msg.Source and ENDSESSION_LOGOFF <> 0 then
ShowMessage('You are logging off...')
else
ShowMessage('You are shutting down or restarting...');
Msg.Result := 0;
end;
siempre muestra el segundo mensaje. Pero si pongo
Código Delphi
[-]
procedure TForm1.WMQueryEndSession(var Msg: TWMQueryEndSession);
begin
inherited;
if Msg.Unused and ENDSESSION_LOGOFF <> 0 then
ShowMessage('You are logging off...')
else
ShowMessage('You are shutting down or restarting...');
Msg.Result := 0;
end;
sí me pone el primer mensaje cuando intento cerrar la sesión.
Esto, con Delphi 7.
// Saludos