public static void DisableCloseButton(string consoleName) { IntPtr windowHandle = NativeWindowApiUtil.FindWindow(null, consoleName); IntPtr closeMenu = NativeWindowApiUtil.GetSystemMenu(windowHandle, IntPtr.Zero); uint scClose = 0xF060; NativeWindowApiUtil.RemoveMenu(closeMenu, scClose, 0x0); }
public static void RegisterCloseConsoleHandle() { NativeWindowApiUtil.SetConsoleCtrlHandler(ct => { if (OnClose != null) { return(OnClose(ct)); } return(false); }, true); }