The code for making the close button disabled is given below. It disables the close button and hence user cannot close console. But one can close console using Task Manager.
#define _WIN32_WINNT 0x0500#include <stdio.h>#include <windows.h>int main(int argc, _TCHAR* argv[]){HWND h;HMENU sm;int i, j, c;LPTSTR buf;// get the handle to the consoleh = GetConsoleWindow();// get handle to the System Menusm = GetSystemMenu(h, 0);// how many items are there?c = GetMenuItemCount(sm);j = -1;buf = (TCHAR*) malloc (256 *sizeof(TCHAR));for (i=0; i<c; i++) {// find the one we wantGetMenuString(sm, i, buf, 255, MF_BYPOSITION);if (!strcmp(buf, "&Close")) {j = i;break;}}// if found, remove that menu itemif (j >= 0)RemoveMenu(sm, j, MF_BYPOSITION);return 0;}
تعليقات: 0
إرسال تعليق