public void Uninstall() { using (WinServiceNative native = new WinServiceNative()) { native.Lock(); native.Open(this.ServiceName); native.Delete(); } }
public new void Stop() { using (WinServiceNative native = new WinServiceNative()) { native.Lock(); native.Open(this.ServiceName); ApiStructs.ServiceStatus ss = native.QueryStatus(); if (ss.CurrentState != ApiEnums.ServiceState.SERVICE_RUNNING) { throw new Win32Exception("Cannot start the service because it is not running"); } } }
public void Install(string arguments) { string location = Assembly.GetEntryAssembly().Location; if (location.Contains(" ")) { location = "\"" + location + "\""; } string imagePath = string.IsNullOrEmpty(arguments) ? location : string.Format("{0} {1}", location, arguments); ApiEnums.ServiceType serviceType = ApiEnums.ServiceType.SERVICE_WIN32_OWN_PROCESS; using (WinServiceNative native = new WinServiceNative()) { native.Lock(); native.Create(this.ServiceName, this.DisplayName, imagePath, serviceType); } }