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

 

posted @ 2018-11-28 15:13  在左手  阅读(2916)  评论(0编辑  收藏  举报