wmsoft 你说的是在你的程序中关机,jcg说的是怎么知道window系统要关机
我想应该是在系统关机时有一个关机的消息发送,
在wind2k下是WM_POWERBROADCAST,在98下我不知道是什么
在你的程序中拦截此消息即可
procedure WMPowerBroadcast(var message: TMessage); message WM_POWERBROADCAST;
procedure TForm1.WMPowerBroadcast(var message: TMessage);
const SkipNextPowerMsg:boolean=True;
begin
if SkipNextPowerMsg then
begin
SetForegroundWindow(Self.Handle);
if Application.MessageBox('是否关闭系统?','警告',MB_OKCANCEL + MB_DEFBUTTON2)<>IDOK then
begin
message.Result := BROADCAST_QUERY_DENY;
SkipNextPowerMsg:=not SkipNextPowerMsg;
end
else
Close;
end
else
SkipNextPowerMsg:=not SkipNextPowerMsg;
end;