本人做了一个小程序,程序一运行便自动隐藏到系统托盘,类似于
WINAMP,现在有一个烦人的问题,就是它会阻止关闭(或重启、注
销)系统,只有把主界面显示出来才不会有这样的问题,我已经在
程序里加了接收关闭系统的消息的过程,为什么当它隐藏时就接收
不到。Procedure WMQueryEndSession(Var Msg: TWMQueryEndSession); message WM_QueryEndSession;Procedure TFrm_Main.WMQueryEndSession(Var Msg: TWMQueryEndSession);
Begin
  Msg.Result := 1;
  Application.Terminate;End;
请各位高手帮我解决一下!!

解决方案 »

  1.   

    我也不知道是怎么回事,好象以前的WINAMP有个版本也有这个问题。当程序的主窗口显示时就可以接收到,隐藏了以后就不行了,为什么会这样的呢。
    系统关机时发送给每个正在执行的程序的消息,难道也有选择性吗—————————————————————————————————
    中国鹰派
    杀光小日本,拒绝韩日货!
      

  2.   

    换成
    procedure MyAppMsg(var Msg: TMsg;var Handled: Boolean);
    begin
        handled := False;
        if Msg.Message = wm_queryendsession then
        begin
           //add your code here
           handled := True;
        end;
    end;Form OnCreate
    begin
       Application.OnMessage := MyAppMsg;
    end;看看行不行的通
      

  3.   

    Winamp有个版本确实是这样的,关注中……
      

  4.   

    naughtyboy()  : 精彩 。借用 您的代码 ,还有,wm_EndSession 应该考虑吗 ?
    ------------------------------------------------------------procedure MyAppMsg(var Msg: TMsg;var Handled: Boolean);
    begin
        if (Msg.Message = wm_queryendsession)  or (Msg.Message = wm_EndSession) then
        begin
          Application.Terminate ;
        end;
    end;Form OnCreate
    begin
       Application.OnMessage := MyAppMsg;
    end;