C# Class Westwind.Windows.Services.WindowsServiceManager

This class handles installation of a Windows Service as well as providing the ability to start stop and detect the state of a Windows Service. Utilizes P/Invoke calls to install the service.
Exibir arquivo Open project: RickStrahl/Westwind.QueueMessageManager Class Usage Examples

Public Methods

Method Description
ContinueService ( string serviceName ) : bool

Pauses a service by name or descriptive name

InstallService ( string svcPath, string svcName, string svcDispName, bool autoStart = true ) : bool

This method installs and runs the service in the service conrol manager.

IsServiceInstalled ( string serviceName ) : bool

Determines whether a service exisits. Pass in the Service Name either by the ServiceName or the descriptive name

IsServiceRunning ( string serviceName ) : bool
PauseService ( string serviceName ) : bool

Pauses a service by name or descriptive name

StartService ( string serviceName ) : bool

Starts a service by name or descriptive name

StopService ( string serviceName ) : bool

Stops a service by name or descriptive name

UnInstallService ( string serviceName ) : bool

This method uninstalls the service from the service conrol manager.

Private Methods

Method Description
CloseServiceHandle ( IntPtr SCHANDLE ) : void
CreateService ( IntPtr SC_HANDLE, string lpSvcName, string lpDisplayName, int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl, string lpPathName, string lpLoadOrderGroup, int lpdwTagId, string lpDependencies, string lpServiceStartName, string lpPassword ) : IntPtr
DeleteService ( IntPtr SVHANDLE ) : int
GetLastError ( ) : int
OpenSCManager ( string lpMachineName, string lpSCDB, int scParameter ) : IntPtr
OpenService ( IntPtr SCHANDLE, string lpSvcName, int dwNumServiceArgs ) : IntPtr
StartService ( IntPtr SVHANDLE, int dwNumServiceArgs, string lpServiceArgVectors ) : int

Method Details

ContinueService() public method

Pauses a service by name or descriptive name
public ContinueService ( string serviceName ) : bool
serviceName string
return bool

InstallService() public method

This method installs and runs the service in the service conrol manager.
public InstallService ( string svcPath, string svcName, string svcDispName, bool autoStart = true ) : bool
svcPath string The complete path of the service.
svcName string Name of the service.
svcDispName string Display name of the service.
autoStart bool
return bool

IsServiceInstalled() public method

Determines whether a service exisits. Pass in the Service Name either by the ServiceName or the descriptive name
public IsServiceInstalled ( string serviceName ) : bool
serviceName string
return bool

IsServiceRunning() public method

public IsServiceRunning ( string serviceName ) : bool
serviceName string
return bool

PauseService() public method

Pauses a service by name or descriptive name
public PauseService ( string serviceName ) : bool
serviceName string
return bool

StartService() public method

Starts a service by name or descriptive name
public StartService ( string serviceName ) : bool
serviceName string
return bool

StopService() public method

Stops a service by name or descriptive name
public StopService ( string serviceName ) : bool
serviceName string
return bool

UnInstallService() public method

This method uninstalls the service from the service conrol manager.
public UnInstallService ( string serviceName ) : bool
serviceName string Name of the service to uninstall.
return bool