屏蔽窗体关闭按钮
[DllImport("USER32.DLL")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, UInt32 bRevert);
private const UInt32 SC_CLOSE = 0x0000F060;
private const UInt32 MF_BYCOMMAND = 0x00000000;
public Form1()
{
InitializeComponent();
IntPtr hMenu = GetSystemMenu(this.Handle, 0);
RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
}
private static extern IntPtr GetSystemMenu(IntPtr hWnd, UInt32 bRevert);
[DllImport("USER32.DLL")]
private static extern UInt32 RemoveMenu(IntPtr hMenu, UInt32 nPosition, UInt32 wFlags);
private static extern UInt32 RemoveMenu(IntPtr hMenu, UInt32 nPosition, UInt32 wFlags);
private const UInt32 SC_CLOSE = 0x0000F060;
private const UInt32 MF_BYCOMMAND = 0x00000000;
public Form1()
{
InitializeComponent();
IntPtr hMenu = GetSystemMenu(this.Handle, 0);
RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
}