Windows操作系统下 使用c++ WIN32API禁用控制台最小化和关闭按钮
#include<Windows.h> //屏蔽控制台最小按钮和关闭按钮 HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMenu(hwnd, false); RemoveMenu(hmenu, SC_CLOSE, MF_BYCOMMAND); LONG style = GetWindowLong(hwnd, GWL_STYLE); style &= ~(WS_MINIMIZEBOX); SetWindowLong(hwnd, GWL_STYLE, style); SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); ShowWindow(hwnd, SW_SHOWNORMAL); DestroyMenu(hmenu); ReleaseDC(hwnd, NULL);