//调用系统API
[DllImport("User32.dll", EntryPoint = "FindWindow")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "GetSystemMenu")]
static extern IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert);
[DllImport("user32.dll", EntryPoint = "RemoveMenu")]
static extern IntPtr RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags);
IntPtr windowHandle = FindWindow(null, "窗体名称可以自己设置");//例--
Console.Title = "test";设置窗体名称test
IntPtr closeMenu = GetSystemMenu(windowHandle, IntPtr.Zero);
uint SC_CLOSE = 0xF060;
RemoveMenu(closeMenu, SC_CLOSE, 0x0);//禁用关闭按钮
温馨提示:答案为网友推荐,仅供参考