X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=console.cpp;h=66c99ea500bf94661f46e87c3f3954952950315f;hb=b5286398f850b432edbddc6d602ab3f33ab086be;hp=771b69c55f1ce4d5e0c32008d4d66642cffae154;hpb=b0a6672810ee06052dc3dcf268274d06f0e82a50;p=nssm.git diff --git a/console.cpp b/console.cpp index 771b69c..66c99ea 100644 --- a/console.cpp +++ b/console.cpp @@ -48,10 +48,15 @@ void alloc_console(nssm_service_t *service) { AllocConsole(); + /* Disable accidental closure. */ + HWND window = GetConsoleWindow(); + HMENU menu = GetSystemMenu(window, false); + EnableMenuItem(menu, SC_CLOSE, MF_GRAYED); + /* Set a title like "[NSSM] Jenkins" */ TCHAR displayname[SERVICE_NAME_LENGTH]; unsigned long len = _countof(displayname); - SC_HANDLE services = open_service_manager(); + SC_HANDLE services = open_service_manager(SC_MANAGER_CONNECT); if (services) { if (! GetServiceDisplayName(services, service->name, displayname, &len)) ZeroMemory(displayname, sizeof(displayname)); CloseServiceHandle(services);