TForm1 = class(TForm)<br> private<br> procedure WMQUERYENDSESSION(var msg:Tmessage);message WM_QUERYENDSESSION;<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>procedure TForm1.WMQUERYENDSESSION(var msg:Tmessage);<br>begin<br> showmessage('Windows要关机了!');<br> msg.Result := 0; //如果返回0,表明不能关闭 <br>end;<br>