Exemple #1
0
 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");
     }
 }
Exemple #2
0
        public NativeService CreateService(string name, string displayname, string cmdline, ServiceRights rights, ServiceStartType starttype = ServiceStartType.AutoStart)
        {
            if (!(this.IsInvalid || this.IsClosed))
            {
                NativeService service = CreateService(this, name, displayname, rights, ServiceType.OwnProcess, starttype, 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
 );
Exemple #6
0
 protected static extern bool StartService(
     NativeService hService,
     uint dwNumServiceArgs,
     string[] lpServiceArgVectors
     );
Exemple #7
0
 protected static extern bool ControlService(
     NativeService hService,
     ServiceControl dwControl,
     out ServiceStatus lpServiceStatus
     );
Exemple #8
0
 protected static extern bool DeleteService(
     NativeService hService
     );