[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> // return value. If the value is not zero, the operation is successful. If the value is zero, the operation fails. /// </Summary> /// <Param name = "ihwnd"> handle of the window </param> /// <returns> whether the window is successful </returns> Public int removexbutton (INT ihwnd) {int isysmenu; const int mf_bycommand = 0x400; // 0x400-Disable isysmenu = getsystemmenu (this. handle. toint32 (), 0); Return removemenu (isysmenu, 6, mf_bycommand);} private void form1_load (Object sender, eventargs E) {// you can determine whether the objective is achieved through the return value of the function. In the constructor, you can determine whether the objective is achieved: int ireturn = removexbutton (this. h Andle. toint32 (); If (ireturn = 0) // If the returned value is non-zero, the operation succeeds. If the returned value is zero, the operation fails. {MessageBox. Show ("error! ");} Else {MessageBox. Show (" success! ");}}