public NativeService OpenService(string name, ServiceRights rights) { if (!(this.IsInvalid || this.IsClosed)) { NativeService service = OpenService(this, name, rights); if (service.IsClosed || service.IsInvalid) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } return(service); } else { throw new ObjectDisposedException("NativeServiceManager"); } }
public NativeService CreateService(string name, string displayname, string cmdline, ServiceRights rights) { if (!(this.IsInvalid || this.IsClosed)) { Logger.Log(LogLevel.Debug, "CreateService({0},{1},{2},{3},{4})", this.handle, name, displayname, cmdline, rights); NativeService service = CreateService(this, name, displayname, rights, ServiceType.OwnProcess, ServiceStartType.AutoStart, ServiceErrorControl.Normal, cmdline, null, IntPtr.Zero, null, null, null); if (service.IsClosed || service.IsInvalid) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } return(service); } else { throw new ObjectDisposedException("NativeServiceManager"); } }
protected static extern bool StartService( NativeService hService, uint dwNumServiceArgs, string[] lpServiceArgVectors );
protected static extern bool DeleteService( NativeService hService );
protected static extern bool ControlService( NativeService hService, ServiceControl dwControl, out ServiceStatus lpServiceStatus );