I would like to check the status of windows (suspend / hibernate) before performing an action.
Example
if suspenso=true then
//executa algo
Thank you in advance.
I would like to check the status of windows (suspend / hibernate) before performing an action.
Example
if suspenso=true then
//executa algo
Thank you in advance.
Based on the @ Guilherme-natal comment and this microsoft article > I was able to set up an example using the WM_POWERBROADCAST message, which is triggered the moment windows enter and suspend. The return of the message in the PowerEvt property is the current status, where PBT_APMSUSPEND represents that it is suspending and PBT_APMRESUMEAUTOMATIC represents that it is leaving the suspend:
TForm1 = class(TForm)
private
fSuspenso: Boolean;
procedure AlterouStatusDoWindows(var Msg: TWMPower); message WM_POWERBROADCAST;
public
end;
...
procedure TForm1.AlterouStatusDoWindows(var Msg: TWMPower);
begin
case MSg.PowerEvt of
PBT_APMSUSPEND: fSuspenso := True;
PBT_APMRESUMEAUTOMATIC: fSuspenso := False;
end;
end;