Esempio n. 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");
     }
 }
Esempio n. 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
 );
Esempio n. 6
0
 protected static extern bool StartService(
     NativeService hService,
     uint dwNumServiceArgs,
     string[] lpServiceArgVectors
     );
Esempio n. 7
0
 protected static extern bool ControlService(
     NativeService hService,
     ServiceControl dwControl,
     out ServiceStatus lpServiceStatus
     );
Esempio n. 8
0
 protected static extern bool DeleteService(
     NativeService hService
     );