Windows 如何禁用控制台关闭按钮
从Stackoverflow上抄的代码
let MF_BYCOMMAND = 0x00000000; let SC_CLOSE = 0xF060; [<DllImport("user32.dll", SetLastError = true)>] extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags); [<DllImport("user32.dll", SetLastError = true)>] extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [<DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)>] extern IntPtr GetConsoleWindow(); let deleteMenu() = DeleteMenu(GetSystemMenu(GetConsoleWindow(), false),SC_CLOSE, MF_BYCOMMAND);
浙公网安备 33010602011771号