From 3b76485ec1d4280a248c83aaffd17b7176b51f35 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Thu, 26 Dec 2013 19:28:56 +0000 Subject: [PATCH] Display canonical service name. When editing or deleting a service we get the service information using the name provided by the user. The name is case-insensitive but case-preserving. Use GetServiceKeyName() to retrieve the canonical name and display that in any messages containing the service name. --- service.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/service.cpp b/service.cpp index b246443..177ac15 100644 --- a/service.cpp +++ b/service.cpp @@ -205,6 +205,10 @@ int pre_edit_service(int argc, TCHAR **argv) { } _sntprintf_s(service->displayname, _countof(service->displayname), _TRUNCATE, _T("%s"), qsc->lpDisplayName); + /* Get the canonical service name. We open it case insensitively. */ + bufsize = _countof(service->name); + GetServiceKeyName(services, service->displayname, service->name, &bufsize); + /* Remember the executable in case it isn't NSSM. */ _sntprintf_s(service->image, _countof(service->image), _TRUNCATE, _T("%s"), qsc->lpBinaryPathName); HeapFree(GetProcessHeap(), 0, qsc); @@ -440,6 +444,12 @@ int remove_service(nssm_service_t *service) { return 3; } + /* Get the canonical service name. We open it case insensitively. */ + unsigned long bufsize = _countof(service->displayname); + GetServiceDisplayName(services, service->name, service->displayname, &bufsize); + bufsize = _countof(service->name); + GetServiceKeyName(services, service->displayname, service->name, &bufsize); + /* Try to delete the service */ if (! DeleteService(service->handle)) { print_message(stderr, NSSM_MESSAGE_DELETESERVICE_FAILED); -- 2.7.4