方法很多<br>(1)放一个ApplicationEvent,在OnMessage中<br>procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;<br> var Handled: Boolean);<br>begin<br> if Msg.message = WM_QUERYENDSESSION then<br> PeekMessage(Msg,Msg.Hwnd,0,0,PM_REMOVE);//换成你要做的<br> inherited;<br>end;<br>(2)<br>关机时会激发Form的OnCloseQuery,设置CanClose可以决定是否关机。