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);

 

posted @ 2022-01-07 19:05  FfD4edyo  阅读(217)  评论(0)    收藏  举报