Inheritance: Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
コード例 #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");
     }
 }
コード例 #2
0
        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");
            }
        }
コード例 #3
0
 protected static extern bool StartService(
     NativeService hService,
     uint dwNumServiceArgs,
     string[] lpServiceArgVectors
 );
コード例 #4
0
 protected static extern bool DeleteService(
     NativeService hService
 );
コード例 #5
0
 protected static extern bool ControlService(
     NativeService hService,
     ServiceControl dwControl,
     out ServiceStatus lpServiceStatus
 );
コード例 #6
0
 protected static extern bool StartService(
     NativeService hService,
     uint dwNumServiceArgs,
     string[] lpServiceArgVectors
     );
コード例 #7
0
 protected static extern bool ControlService(
     NativeService hService,
     ServiceControl dwControl,
     out ServiceStatus lpServiceStatus
     );
コード例 #8
0
 protected static extern bool DeleteService(
     NativeService hService
     );