Browse Source

Added service_status_text().

Function to get a string representation of a service status, eg
SERVICE_RUNNING.
Iain Patterson 10 năm trước cách đây
mục cha
commit
8d884cbd58
2 tập tin đã thay đổi với 14 bổ sung0 xóa
  1. 13 0
      service.cpp
  2. 1 0
      service.h

+ 13 - 0
service.cpp

@@ -1292,6 +1292,19 @@ TCHAR *service_control_text(unsigned long control) {
   }
 }
 
+TCHAR *service_status_text(unsigned long status) {
+  switch (status) {
+    case SERVICE_STOPPED: return _T("SERVICE_STOPPED");
+    case SERVICE_START_PENDING: return _T("SERVICE_START_PENDING");
+    case SERVICE_STOP_PENDING: return _T("SERVICE_STOP_PENDING");
+    case SERVICE_RUNNING: return _T("SERVICE_RUNNING");
+    case SERVICE_CONTINUE_PENDING: return _T("SERVICE_CONTINUE_PENDING");
+    case SERVICE_PAUSE_PENDING: return _T("SERVICE_PAUSE_PENDING");
+    case SERVICE_PAUSED: return _T("SERVICE_PAUSED");
+    default: return 0;
+  }
+}
+
 void log_service_control(TCHAR *service_name, unsigned long control, bool handled) {
   TCHAR *text = service_control_text(control);
   unsigned long event;

+ 1 - 0
service.h

@@ -104,6 +104,7 @@ typedef struct {
 
 void WINAPI service_main(unsigned long, TCHAR **);
 TCHAR *service_control_text(unsigned long);
+TCHAR *service_status_text(unsigned long);
 void log_service_control(TCHAR *, unsigned long, bool);
 unsigned long WINAPI service_control_handler(unsigned long, unsigned long, void *, void *);