C# Класс 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.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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

Описание методов

ContinueService() публичный Метод

Pauses a service by name or descriptive name
public ContinueService ( string serviceName ) : bool
serviceName string
Результат bool

InstallService() публичный Метод

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
Результат bool

IsServiceInstalled() публичный Метод

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
Результат bool

IsServiceRunning() публичный Метод

public IsServiceRunning ( string serviceName ) : bool
serviceName string
Результат bool

PauseService() публичный Метод

Pauses a service by name or descriptive name
public PauseService ( string serviceName ) : bool
serviceName string
Результат bool

StartService() публичный Метод

Starts a service by name or descriptive name
public StartService ( string serviceName ) : bool
serviceName string
Результат bool

StopService() публичный Метод

Stops a service by name or descriptive name
public StopService ( string serviceName ) : bool
serviceName string
Результат bool

UnInstallService() публичный Метод

This method uninstalls the service from the service conrol manager.
public UnInstallService ( string serviceName ) : bool
serviceName string Name of the service to uninstall.
Результат bool