添加termination事件看看
调用application.exit()方法退出
不用CLOSE()

解决方案 »

  1.   

    MSDN的CLOSING事件说明有中:CAUTION   The Form.Closed and Form.Closing events are not raised when the Application.Exit method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the Form.Close method for each open form individually before calling the Exit method.调用application.exit()方法不会触发closing事件
    那就可以退出了
      

  2.   

    关键是关机的时候怎么调用Application.exit()来关闭应用程序呢?
      

  3.   

    private void FrmMain_Closing(object sender,System.ComponentModel.CancelEventArgs e)
    {
    if (System.Windows.Forms.MessageBox.Show(this,"是否真要关闭系统?","系统提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
                  Application.Exit();
    else
    e.Cancel = true;
    }
      

  4.   

    关机的时候能自动关闭程序
    现在因为closing函数重写了,退不出来
    能指点一下吗?
      

  5.   

    在你的程序中加入发下的代码就可以了:
    (你再按你的程序的意思改一下就可以了)
    protected override void WndProc(ref Message m)
    {
    int WM_QUERYENDSESSION = 0x0011;
    if (m.Msg ==WM_QUERYENDSESSION)
    {
    if (MessageBox.Show("本程序将要退出","提示",MessageBoxButtons.OK)==DialogResult.OK)
    {
    Application.Exit();
    return;
    }
    }
    else
    {
    base.WndProc (ref m);
    }
    }
      

  6.   

    我不知道如何来取消Windows的注销或关机,想来想去还是用如下的代码更好一些,这样当Windows关闭或注销时会让本程序退出以便让Windows关闭或注销.如下,如果哪位大哥知道怎么在这个时候来取消Windows关闭或注销请在此告知,我另开一新帖给100分!
    protected override void WndProc(ref Message m)
    {
    int WM_QUERYENDSESSION = 0x0011;
    if (m.Msg ==WM_QUERYENDSESSION)
    {
    Application.Exit();
    return;
    }
    else
    {
    base.WndProc (ref m);
    }
    }
      

  7.   

    给你右下角那个冬冬加个ContextMenu 在他的MenuItem Click 事件里头实现 application.exit.
    你不是知道flashget是怎么做的嘛?
      

  8.   

    谢谢 hbxtlhx(下着春雨的天)