Disable console window's close menu item.

We can't trap Control-C in a service context but we can grey out the
close window button on the console window.  Doing so goes some way
toward preventing accidental closure.

Thanks Hadrien Kohl.
master
Iain Patterson 11 years ago
parent 620fc9f569
commit a8cb4778bd

@ -681,6 +681,7 @@ and/or stderr which attempt to read from stdin would fail.
Thanks to Czenda Czendov for help with Visual Studio 2013 and Server 2012R2. Thanks to Czenda Czendov for help with Visual Studio 2013 and Server 2012R2.
Thanks to Alessandro Gherardi for reporting and draft fix of the bug whereby Thanks to Alessandro Gherardi for reporting and draft fix of the bug whereby
the second restart of the application would have a corrupted environment. the second restart of the application would have a corrupted environment.
Thanks to Hadrien Kohl for suggesting to disable the console window's menu.
Licence Licence
------- -------

@ -48,6 +48,11 @@ void alloc_console(nssm_service_t *service) {
AllocConsole(); AllocConsole();
/* Disable accidental closure. */
HWND window = GetConsoleWindow();
HMENU menu = GetSystemMenu(window, false);
EnableMenuItem(menu, SC_CLOSE, MF_GRAYED);
/* Set a title like "[NSSM] Jenkins" */ /* Set a title like "[NSSM] Jenkins" */
TCHAR displayname[SERVICE_NAME_LENGTH]; TCHAR displayname[SERVICE_NAME_LENGTH];
unsigned long len = _countof(displayname); unsigned long len = _countof(displayname);

Loading…
Cancel
Save