Board index » delphi » Determine if entering Standby Mode

Determine if entering Standby Mode

  Is there an API that is executed before the computer goes into
standby mode (Start button/Shutdown.../Standby)?  Or possibly some
other way to detect that the computer is about to go into this mode?

  Thanks.

 

Re:Determine if entering Standby Mode


Check if you receive a WM_POWERBROADCAST message in the
Application.OnMessage event.

"GCS" <batt...@flash.net> schreef in bericht
news:3AAE81EC.FE4A5DDA@flash.net...

Quote
>   Is there an API that is executed before the computer goes into
> standby mode (Start button/Shutdown.../Standby)?  Or possibly some
> other way to detect that the computer is about to go into this mode?

>   Thanks.

Re:Determine if entering Standby Mode


  Yes, that worked - Thanks!

An example:

type
  TForm1 = class(TForm)
    procedure AppOnMessage(var Msg: TMsg; var Handled:Boolean);
...

procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled:Boolean);
begin
   case Msg.Message of WM_POWERBROADCAST:
        begin
        Form1.Label1.Caption := 'WM_POWERBROADCAST'; //show it works
        end;
   end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   Application.OnMessage := AppOnMessage;
end;

end.

Quote
"M.H. Avegaart" wrote:

> Check if you receive a WM_POWERBROADCAST message in the
> Application.OnMessage event.

> "GCS" <batt...@flash.net> schreef in bericht
> news:3AAE81EC.FE4A5DDA@flash.net...
> >   Is there an API that is executed before the computer goes into
> > standby mode (Start button/Shutdown.../Standby)?  Or possibly some
> > other way to detect that the computer is about to go into this mode?

> >   Thanks.

Other Threads