这个,不大可能不过你可以在closeing事件中把事件e.Cancel=true;这样可以保证不关闭

解决方案 »

  1.   

    private void yourformname_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                e.Cancel=true;        }
      

  2.   

    下面是VB的实现.
      //**************************************
        // Name: Disable Form Close Button
        // Description:This code is used to disable the "X" form button (that one top right) in a form
        // By: Claudio Di Flumeri
        //
        //
        // Inputs:The Handle of the form
        //
        // Returns:None
        //
        //Assumes:None
        //
        //Side Effects:None
        //This code is copyrighted and has limited warranties.
        //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.774/lngWId.10/qx/vb/scripts/ShowCode.htm
        //for details.
        //**************************************
        
        Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Long) As IntPtr
        Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
        Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As IntPtr) As Integer
        Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As IntPtr) As Boolean
        //     '
        Private Const MF_BYPOSITION = &H400
        Private Const MF_REMOVE = &H1000
        Private Const MF_DISABLED = &H2
        //     '
        Public Sub DisableCloseButton(ByVal hwnd As IntPtr)
        Dim hMenu As IntPtr
        Dim menuItemCount As Integer
        //     '
        'Obtain the handle to the form's system 
        //     menu
        hMenu = GetSystemMenu(hwnd, False)
        //     '
        //     'Obtain the number of items in the menu
        menuItemCount = GetMenuItemCount(hMenu)
        //     '
        'Remove the system menu Close menu item.
        //     
        //     'The menu item is 0-based, so the last
        //     'item on the menu is menuItemCount - 1
        Call RemoveMenu(hMenu, menuItemCount - 1, _
        MF_DISABLED Or MF_BYPOSITION)
        //     '
        //     'Remove the system menu separator line
        Call RemoveMenu(hMenu, menuItemCount - 2, _
        MF_DISABLED Or MF_BYPOSITION)
        //     '
        //     'Force a redraw of the menu. This
        //     'refreshes the titlebar, dimming the X
        Call DrawMenuBar(hwnd)
        End Sub
        //     '
        //     '
        '------------------- USAGE -------------
        //     ------
        //     'Put this in the Load Event of a Form
        //     '
        DisableCloseButton(Me.Handle)
      

  3.   

    我以前在vb中用api实现的,不过都是一年多以前的事了。都忘的差不多了
      

  4.   

    c++builder的
       
      HWND m_hWnd=GetSystemMenu(this->Handle,false);    //关闭按钮
       EnableMenuItem(m_hWnd,SC_CLOSE,MF_GRAYED);
      

  5.   

    C#的搞成了.
    ==============================
            private void yourform_Load(object sender, System.EventArgs e)
            {
                int lSysMenu;
                const int  MF_BYPOSITION = 1024;
                lSysMenu = WinApi.GetSystemMenu(this.Handle.ToInt32(), 0);
                WinApi.RemoveMenu(lSysMenu, 6, MF_BYPOSITION);
                //WinApi.RemoveMenu(lSysMenu, 5, MF_BYPOSITION);
            }
    =====================
    public class WinApi
    {
    [DllImport("User32.dll")]
    public static extern int GetSystemMenu(int hWnd, int bRevert);
    [DllImport("User32.dll")]
    public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags);
    }
      

  6.   

    http://expert.csdn.net/Expert/topic/1280/1280722.xml?temp=.4198114
      

  7.   

    调用DLL可以这样啊[DllImport("User32.dll")]
      

  8.   

    实在不行就override WndProc
    switch(m.Message)
    {
        case WM_CLOSE://好像是这个,如果不行就试试WM_DESTORY什么的。
        {
           break;
        }
        default:
        {
           base.WndProc(ref m);
           break;
        }
    }