Occasionally, somebody wants to create a window without a Close button.
The only way to get rid of the Close button is not to have a System menu at all: Remove the WS_ style from the window. But that also gets rid of the Minimize and Maximize buttons, so it’s kind of drastic.
If you want a System menu, or if you want Minimize and Maximize buttons, you can at least disable the Close button by disabling the SC_CLOSE menu item.
HMENU menu = GetSystemMenu(hwnd, FALSE); EnableMenuItem(menu, SC_CLOSE, MF_DISABLED);
Of course, you could use the nuclear option and implement your own custom title bar. Then you can do whatever you want. But most people are probably not willing to take things to such an extreme.
But really, try not to hide or disable the Close the button at all. End users don’t like it. It makes them feel trapped.
Ahh my work IT has some third-party apps that do this. As a responsible employee I try not to go to Task Manager and kill them (I have found a good way to work is if IT is not mad at you). But they also seem to forget you can just fling them to the bottom right corner of the screen so only a smidge is visible until they decide to go away on their own.