禁用控制台的关闭按钮
class Program { [DllImport("user32.dll")] public static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);// 删除菜单 [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);// 获取系统菜单句柄 [DllImport("kernel32.dll", ExactSpelling = true)] private static extern IntPtr GetConsoleWindow();// 获取控制台窗口句柄 static void Main(string[] args) { DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), 0xF060, 0x00000000); } }

浙公网安备 33010602011771号