unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 =
class(TForm)
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
procedure WMPowerBroadcast(
var Msg: TMessage);
message WM_POWERBROADCAST;
end;
const
PBT_APMQUERYSUSPEND = $0000;
PBT_APMQUERYSTANDBY = $0001;
PBT_APMQUERYSUSPENDFAILED = $0002;
PBT_APMQUERYSTANDBYFAILED = $0003;
PBT_APMSUSPEND = $0004;
PBT_APMSTANDBY = $0005;
PBT_APMRESUMECRITICAL = $0006;
PBT_APMRESUMESUSPEND = $0007;
PBT_APMRESUMESTANDBY = $0008;
PBTF_APMRESUMEFROMFAILURE = $00000001;
PBT_APMBATTERYLOW = $0009;
PBT_APMPOWERSTATUSCHANGE = $000A;
PBT_APMOEMEVENT = $000B;
PBT_APMRESUMEAUTOMATIC = $0012;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMPowerBroadcast(
var Msg: TMessage);
begin
showmessage('
PowerBroadcast erhalten');
if (Msg.WParam = PBT_APMSUSPEND)
or
(Msg.WParam = PBT_APMSTANDBY)
then begin
// windows want to go into standby or hibernation mode
// Hier hin, was getan werden muss, bevor Windows in den Standby darf,
// z.B. Netzwerk- oder Datenbankverbindungen trennen, Timer abstellen, etc.
showmessage('
Standby/Ruhezustand');
Msg.Result := 1;
// allow standby/hibernation
//Msg.Result := BROADCAST_QUERY_DENY; // deny standby/hibernation
end else if (Msg.WParam = PBT_APMRESUMECRITICAL)
or
(Msg.WParam = PBT_APMRESUMESUSPEND)
or
(Msg.WParam = PBT_APMRESUMESTANDBY)
then begin
// windows returns from standby or hibernation
// Hier z.B. Verbindungen wiederherstellen
showmessage('
Rückkehr aus Standby/Ruhezustand');
end;
end;
//inherited WndProc(MyMessage);
end.