aboutsummaryrefslogtreecommitdiffstats
path: root/win/rfb_win32/Service.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'win/rfb_win32/Service.cxx')
-rw-r--r--win/rfb_win32/Service.cxx39
1 files changed, 20 insertions, 19 deletions
diff --git a/win/rfb_win32/Service.cxx b/win/rfb_win32/Service.cxx
index bc9875e5..d28fdb75 100644
--- a/win/rfb_win32/Service.cxx
+++ b/win/rfb_win32/Service.cxx
@@ -22,18 +22,19 @@
#include <config.h>
#endif
+#include <core/Exception.h>
+#include <core/LogWriter.h>
+#include <core/string.h>
+
#include <rfb_win32/Service.h>
#include <rfb_win32/MsgWindow.h>
#include <rfb_win32/ModuleFileName.h>
#include <rfb_win32/Registry.h>
#include <rfb_win32/Handle.h>
-#include <logmessages/messages.h>
-#include <rdr/Exception.h>
-#include <rfb/LogWriter.h>
-#include <rfb/util.h>
+#include <logmessages/messages.h>
-using namespace rdr;
+using namespace core;
using namespace rfb;
using namespace win32;
@@ -335,7 +336,7 @@ bool rfb::win32::registerService(const char* name,
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
- throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
+ throw core::win32_error("Unable to open Service Control Manager", GetLastError());
// - Add the service
ServiceHandle handle = CreateService(scm,
@@ -344,7 +345,7 @@ bool rfb::win32::registerService(const char* name,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
cmdline.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr);
if (!handle)
- throw rdr::win32_error("Unable to create service", GetLastError());
+ throw core::win32_error("Unable to create service", GetLastError());
// - Set a description
SERVICE_DESCRIPTION sdesc = {(LPTSTR)desc};
@@ -380,14 +381,14 @@ bool rfb::win32::unregisterService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
- throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
+ throw core::win32_error("Unable to open Service Control Manager", GetLastError());
// - Create the service
ServiceHandle handle = OpenService(scm, name, SC_MANAGER_ALL_ACCESS);
if (!handle)
- throw rdr::win32_error("Unable to locate the service", GetLastError());
+ throw core::win32_error("Unable to locate the service", GetLastError());
if (!DeleteService(handle))
- throw rdr::win32_error("Unable to remove the service", GetLastError());
+ throw core::win32_error("Unable to remove the service", GetLastError());
// - Register the event log source
RegKey hk;
@@ -407,16 +408,16 @@ bool rfb::win32::startService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
+ throw core::win32_error("Unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_START);
if (!handle)
- throw rdr::win32_error("Unable to open the service", GetLastError());
+ throw core::win32_error("Unable to open the service", GetLastError());
// - Start the service
if (!StartService(handle, 0, nullptr))
- throw rdr::win32_error("Unable to start the service", GetLastError());
+ throw core::win32_error("Unable to start the service", GetLastError());
Sleep(500);
@@ -427,17 +428,17 @@ bool rfb::win32::stopService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
+ throw core::win32_error("Unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_STOP);
if (!handle)
- throw rdr::win32_error("Unable to open the service", GetLastError());
+ throw core::win32_error("Unable to open the service", GetLastError());
// - Start the service
SERVICE_STATUS status;
if (!ControlService(handle, SERVICE_CONTROL_STOP, &status))
- throw rdr::win32_error("Unable to stop the service", GetLastError());
+ throw core::win32_error("Unable to stop the service", GetLastError());
Sleep(500);
@@ -448,17 +449,17 @@ DWORD rfb::win32::getServiceState(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::win32_error("Unable to open Service Control Manager", GetLastError());
+ throw core::win32_error("Unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_INTERROGATE);
if (!handle)
- throw rdr::win32_error("Unable to open the service", GetLastError());
+ throw core::win32_error("Unable to open the service", GetLastError());
// - Get the service status
SERVICE_STATUS status;
if (!ControlService(handle, SERVICE_CONTROL_INTERROGATE, (SERVICE_STATUS*)&status))
- throw rdr::win32_error("Unable to query the service", GetLastError());
+ throw core::win32_error("Unable to query the service", GetLastError());
return status.dwCurrentState;
}