#region 禁用右上角的关闭按扭
[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);
/// <summary>
/// 返回值,非零表示成功,零表示失败。
/// </summary>
/// <param name="iHWND">窗口的句柄</param>
/// <returns>是否成功</returns>
public int RemoveXButton(int iHWND)
{
int iSysMenu;
const int MF_BYCOMMAND = 0x400; //0x400-关闭
iSysMenu = GetSystemMenu(this.Handle.ToInt32(), 0);
return RemoveMenu(iSysMenu, 6, MF_BYCOMMAND);
}
#endregion