windows/SysLocalAPIManager.cpp File Reference
#include "SysLocalAPIManager.hpp"
#include "LocalAPIManager.hpp"
#include <stdio.h>
Include dependency graph for windows/SysLocalAPIManager.cpp:

Go to the source code of this file.

Macros

#define SERVICENAME   "RXAPI"
 

Enumerations

enum  WinServiceStatusT {
  WS_IS_RUNNING = 0 , WS_NOT_INSTALLED , WS_IS_DISABLED , WS_IS_STOPPED ,
  WS_NOT_PRIVILEGED , WS_UNKNOWN
}
 

Functions

static bool hasServiceStarted (SC_HANDLE hService)
 
static WinServiceStatusT getServiceStatus (SC_HANDLE *phSCM)
 
bool startAsService (void)
 

Macro Definition Documentation

◆ SERVICENAME

#define SERVICENAME   "RXAPI"

Definition at line 79 of file windows/SysLocalAPIManager.cpp.

Enumeration Type Documentation

◆ WinServiceStatusT

Enumerator
WS_IS_RUNNING 
WS_NOT_INSTALLED 
WS_IS_DISABLED 
WS_IS_STOPPED 
WS_NOT_PRIVILEGED 
WS_UNKNOWN 

Definition at line 82 of file windows/SysLocalAPIManager.cpp.

Function Documentation

◆ getServiceStatus()

static WinServiceStatusT getServiceStatus ( SC_HANDLE *  phSCM)
static

Get the status of the rxapi service, which could be not installed as a service.

Parameters
phSCMPointer to a handle for the Service Control Manager. If rxapi is installed as a service, and not disabled, an open handle is returned here. Otherwise the handle is set to NULL.
Returns
A WinServiceStatusT enum indicating the status of rxapi as a Windows service.

Definition at line 185 of file windows/SysLocalAPIManager.cpp.

References hasServiceStarted(), SERVICENAME, WS_IS_DISABLED, WS_IS_RUNNING, WS_IS_STOPPED, WS_NOT_PRIVILEGED, and WS_UNKNOWN.

Referenced by startAsService().

◆ hasServiceStarted()

static bool hasServiceStarted ( SC_HANDLE  hService)
static

Reports if the rxapi service is in the running state at the time this function returns. If the service is in the START PENDING state the function waits untils the service is running or has timed out.

Parameters
hServiceOpened service handle, must have the SERVICE_QUERY_STATUS privilege.
Returns
True the service is not running, otherwise false.

Definition at line 103 of file windows/SysLocalAPIManager.cpp.

Referenced by getServiceStatus(), and startAsService().

◆ startAsService()

bool startAsService ( void  )

Determines if rxapi is installed and running as a service.

If rxapi is installed as a service, but not running an attempt is made to start the service. When the service is not disabled, and the user (owner of this running process) has the authority to start the rxapi service, then the attempt should succeed.

If the function attempts to start the service, it will wait to see that the service actually starts. If the above conditions are met, then the service will start.

Returns
True if the service is started and running, otherwise false.
Note
Both the service control manager and the service itself are opened with the minimum access rights needed to accomplish the task. On Vista this is especially important because it prevents unnecessary failures.

Definition at line 273 of file windows/SysLocalAPIManager.cpp.

References getServiceStatus(), hasServiceStarted(), SERVICENAME, WS_IS_DISABLED, WS_IS_RUNNING, WS_NOT_INSTALLED, and WS_NOT_PRIVILEGED.