也可以使用api,先添加引用 using System.Runtime.InteropServices; //使窗体的关闭按纽变灰 int lSysMenu; const int MF_BYPOSITION = 1024; lSysMenu = WinApi.GetSystemMenu(this.Handle.ToInt32(), 0); WinApi.RemoveMenu(lSysMenu, 6, 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); }
using System.Runtime.InteropServices;
//使窗体的关闭按纽变灰
int lSysMenu;
const int MF_BYPOSITION = 1024;
lSysMenu = WinApi.GetSystemMenu(this.Handle.ToInt32(), 0);
WinApi.RemoveMenu(lSysMenu, 6, 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);
}