diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-10-17 12:55:05 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-10-17 12:55:05 +0000 |
commit | c16cf90559fad4d8382f3cd3f92ca78f35ed2095 (patch) | |
tree | af01021204c8fa46986388f1fde6721dca1a7728 /bin/bbackupd/Win32ServiceFunctions.cpp | |
parent | 7239aaba320fbc24dd608585ca417f804dab1950 (diff) |
Use the specified service name when installing and removing the service.
Pass the service name on the service command line, and use it for event
log messages.
(merges [1856])
Diffstat (limited to 'bin/bbackupd/Win32ServiceFunctions.cpp')
-rw-r--r-- | bin/bbackupd/Win32ServiceFunctions.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/bin/bbackupd/Win32ServiceFunctions.cpp b/bin/bbackupd/Win32ServiceFunctions.cpp index 30b7b9bf..a7bf6bd9 100644 --- a/bin/bbackupd/Win32ServiceFunctions.cpp +++ b/bin/bbackupd/Win32ServiceFunctions.cpp @@ -199,7 +199,7 @@ int OurService(const char* pConfigFileName) return 0; } -int InstallService(const char* pConfigFileName) +int InstallService(const char* pConfigFileName, const std::string& rServiceName) { if (pConfigFileName != NULL) { @@ -235,7 +235,7 @@ int InstallService(const char* pConfigFileName) cmd[sizeof(cmd)-1] = 0; std::string cmdWithArgs(cmd); - cmdWithArgs += " -s"; + cmdWithArgs += " -s -S \"" + rServiceName + "\""; if (pConfigFileName != NULL) { @@ -244,10 +244,12 @@ int InstallService(const char* pConfigFileName) cmdWithArgs += "\""; } + std::string serviceDesc = "Box Backup (" + rServiceName + ")"; + SC_HANDLE newService = CreateService( scm, - SERVICE_NAME, - "Box Backup", + rServiceName.c_str(), + serviceDesc.c_str(), SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, @@ -312,7 +314,7 @@ int InstallService(const char* pConfigFileName) return 0; } -int RemoveService(void) +int RemoveService(const std::string& rServiceName) { SC_HANDLE scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE); @@ -323,7 +325,7 @@ int RemoveService(void) return 1; } - SC_HANDLE service = OpenService(scm, SERVICE_NAME, + SC_HANDLE service = OpenService(scm, rServiceName.c_str(), SERVICE_ALL_ACCESS|DELETE); DWORD err = GetLastError(); CloseServiceHandle(scm); |