Remove the Close window option

I am writing a personal program and it has a password for it. I disabled the exit button in the top right corner but someone can still close it by right clicking the program on the task bar and clicking 'close window'. So I am asking how do I make the close window option not active. I know it is possible because when I had Norton security it wouldn't let me close it.

Please help.
You can use the GetSystemMenu Win API function to retrieve the system menu and then you could use the RemoveMenu function to remove the menu item (or you could use ModifyMenu passing in the appropriate flags to disable the menu item).

GetSystemMenu:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms647985(v=vs.85).aspx

RemoveMenu:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms647994(v=vs.85).aspx

ModifyMenu:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms647993(v=vs.85).aspx
OK I looked through all those links and I did this awhile back and forgot to respond.
This is what I did:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <windows.h>
#include <string>
#include <fstream>
#include <mmsystem.h>
#include <conio.h>
#include<process.h>
#define _WIN32_WINNT 0x0500
#pragma comment (lib, "winmm.lib")
using namespace std;
int main(){
HWND hStartBtn = FindWindowEx(NULL, NULL, MAKEINTATOM(0xC017), TEXT("Start"));
	if (hStartBtn != NULL)
	{
    ShowWindow(hStartBtn, FALSE);
	}
	ShowWindow(FindWindow(L"Shell_TrayWnd",L""),SW_HIDE);
	RemoveMenu(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE , MF_GRAYED);
    DrawMenuBar(GetConsoleWindow());
}

A lot of those header files are for other parts of my program.
Topic archived. No new replies allowed.