1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include <Windows.h> int main() { HWND hWnd = GetConsoleWindow(); //获得cmd窗口句柄 RECT rc; GetWindowRect(hWnd, &rc); //获得cmd窗口对应矩形 //改变cmd窗口风格 SetWindowLongPtr(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX); //因为风格涉及到边框改变,必须调用SetWindowPos,否则无效果 SetWindowPos(hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL); return 0; } |
摘自网络,锁定CMD窗口
发表回复