summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2000-03-22 17:54:59 +0000
committerSteve Huston <shuston@riverace.com>2000-03-22 17:54:59 +0000
commit683d5f238286daf51707387f4a72cdfeb7520892 (patch)
tree753c9ea49107a8f5bf6a7ab959672cd634b8dcf8
parentefdec32251fdbabb0503121db63e88bd683d5a5c (diff)
downloadATCD-683d5f238286daf51707387f4a72cdfeb7520892.tar.gz
ChangeLogTag:Wed Mar 22 12:01:22 2000 Steve Huston <shuston@riverace.com>
-rw-r--r--ace/NT_Service.cpp28
-rw-r--r--ace/NT_Service.h8
-rw-r--r--ace/NT_Service.i13
3 files changed, 44 insertions, 5 deletions
diff --git a/ace/NT_Service.cpp b/ace/NT_Service.cpp
index 8780a606aa7..f7c0c543fa8 100644
--- a/ace/NT_Service.cpp
+++ b/ace/NT_Service.cpp
@@ -26,6 +26,7 @@ ACE_NT_Service::~ACE_NT_Service (void)
}
delete [] desc_;
delete [] name_;
+ delete [] host_;
}
// This default implementation of ACE_NT_Service::open sets the
@@ -144,6 +145,27 @@ ACE_NT_Service::name (LPCTSTR name, LPCTSTR desc)
desc_ = ACE::strnew (desc);
}
+void
+ACE_NT_Service::host (LPCTSTR host)
+{
+ delete [] host_;
+
+ if (svc_sc_handle_ != 0)
+ {
+ CloseServiceHandle (svc_sc_handle_);
+ svc_sc_handle_ = 0;
+ }
+
+ if (host == 0)
+ {
+ host_ = 0;
+ }
+ else
+ {
+ host_ = ACE::strnew (host);
+ }
+}
+
int
ACE_NT_Service::insert (DWORD start_type,
DWORD error_control,
@@ -163,7 +185,7 @@ ACE_NT_Service::insert (DWORD start_type,
exe_path = this_exe;
}
- SC_HANDLE sc_mgr = OpenSCManager (0, 0, SC_MANAGER_ALL_ACCESS);
+ SC_HANDLE sc_mgr = OpenSCManager (this->host (), 0, SC_MANAGER_ALL_ACCESS);
if (sc_mgr == 0)
return -1;
@@ -375,7 +397,7 @@ ACE_NT_Service::test_access (DWORD desired_access)
{
int status = -1; // Guilty until proven innocent
- SC_HANDLE sc_mgr = OpenSCManager (0,
+ SC_HANDLE sc_mgr = OpenSCManager (this->host (),
0,
GENERIC_READ);
if (sc_mgr != 0)
@@ -448,7 +470,7 @@ ACE_NT_Service::svc_sc_handle (void)
{
if (svc_sc_handle_ == 0)
{
- SC_HANDLE sc_mgr = OpenSCManager (0,
+ SC_HANDLE sc_mgr = OpenSCManager (this->host (),
0,
SC_MANAGER_ALL_ACCESS);
if (sc_mgr != 0)
diff --git a/ace/NT_Service.h b/ace/NT_Service.h
index 51a39e17f80..edc24e36265 100644
--- a/ace/NT_Service.h
+++ b/ace/NT_Service.h
@@ -155,6 +155,12 @@ public:
LPCTSTR desc (void) const;
// Get the service description.
+ void host (LPCTSTR host);
+ // Sets the host machine
+
+ LPCTSTR host (void) const;
+ // Get the host machine.
+
int insert (DWORD start_type = SERVICE_DEMAND_START,
DWORD error_control = SERVICE_ERROR_IGNORE,
LPCTSTR exe_path = 0,
@@ -303,6 +309,7 @@ protected:
// Service's SCM handle
LPTSTR name_;
LPTSTR desc_;
+ LPTSTR host_;
};
@@ -342,6 +349,7 @@ protected:
}
#define ACE_NT_SERVICE_REFERENCE(SVCNAME) \
+extern ACE_NT_Service * _ace_nt_svc_obj_##SVCNAME; \
extern VOID WINAPI ace_nt_svc_main_##SVCNAME (DWORD dwArgc, LPTSTR *lpszArgv);
#define ACE_NT_SERVICE_ENTRY(SVCDESC, SVCNAME) \
diff --git a/ace/NT_Service.i b/ace/NT_Service.i
index 595a85dc1ea..65083170e94 100644
--- a/ace/NT_Service.i
+++ b/ace/NT_Service.i
@@ -9,7 +9,8 @@ ACE_NT_Service::ACE_NT_Service (DWORD start_timeout,
svc_handle_(0),
svc_sc_handle_(0),
name_(0),
- desc_(0)
+ desc_(0),
+ host_(0)
{
svc_status_.dwServiceType = service_type;
svc_status_.dwCurrentState = 0;
@@ -30,7 +31,8 @@ ACE_NT_Service::ACE_NT_Service (LPCTSTR name,
svc_handle_(0),
svc_sc_handle_(0),
name_(ACE::strnew(name)),
- desc_(ACE::strnew(desc))
+ desc_(ACE::strnew(desc)),
+ host_(0)
{
svc_status_.dwServiceType = service_type;
svc_status_.dwCurrentState = 0;
@@ -62,6 +64,13 @@ ACE_NT_Service::desc (void) const
return desc_;
}
+ACE_INLINE
+LPCTSTR
+ACE_NT_Service::host (void) const
+{
+ return host_;
+}
+
ACE_INLINE void
ACE_NT_Service::svc_handle(const SERVICE_STATUS_HANDLE new_svc_handle)
{