Пример #1
0
 bool INativeInterop.ChangeServiceConfigW(ServiceHandle service, ServiceType serviceType
                                          , ServiceStartType startType, ErrorSeverity errorSeverity, string binaryPath
                                          , string loadOrderGroup, System.IntPtr outUIntTagId
                                          , string dependencies, string serviceUserName
                                          , string servicePassword, string displayName)
 {
     return(ChangeServiceConfigW(service, serviceType, startType, errorSeverity, binaryPath
                                 , loadOrderGroup, outUIntTagId, dependencies, serviceUserName, servicePassword, displayName));
 }
Пример #2
0
 private static extern bool ChangeServiceConfigW(
     ServiceHandle service,
     ServiceType serviceType,
     ServiceStartType startType,
     ErrorSeverity errorSeverity,
     string binaryPath,
     string loadOrderGroup,
     IntPtr outUIntTagId,
     string dependencies,
     string serviceUserName,
     string servicePassword,
     string displayName);
Пример #3
0
        public virtual bool TryOpenService(string serviceName
                                           , ServiceControlAccessRights desiredControlAccess
                                           , out ServiceHandle serviceHandle
                                           , out System.ComponentModel.Win32Exception errorException)
        {
            ServiceHandle service = NativeInterop.OpenServiceW(this, serviceName, desiredControlAccess);

            service.NativeInterop = NativeInterop;

            if (service.IsInvalid)
            {
                errorException = new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error());
                serviceHandle  = null;
                return(false);
            }

            serviceHandle  = service;
            errorException = null;
            return(true);
        }
Пример #4
0
        public ServiceHandle CreateService(string serviceName
                                           , string displayName
                                           , string binaryPath
                                           , ServiceType serviceType
                                           , ServiceStartType startupType
                                           , ErrorSeverity errorSeverity
                                           , Win32ServiceCredentials credentials)
        {
            ServiceHandle service = NativeInterop.CreateServiceW(this, serviceName, displayName, ServiceControlAccessRights.All, serviceType, startupType, errorSeverity,
                                                                 binaryPath, null,
                                                                 System.IntPtr.Zero, null, credentials.UserName, credentials.Password);

            service.NativeInterop = NativeInterop;

            if (service.IsInvalid)
            {
                throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error());
            }

            return(service);
        }
Пример #5
0
 private static extern bool ChangeServiceConfig2W(ServiceHandle service, ServiceConfigInfoTypeLevel infoTypeLevel, IntPtr info);
Пример #6
0
 private static extern bool DeleteService(ServiceHandle service);
Пример #7
0
 private static extern bool StartServiceW(ServiceHandle service, uint argc, IntPtr wargv);
Пример #8
0
 bool INativeInterop.ChangeServiceConfig2W(ServiceHandle service, ServiceConfigInfoTypeLevel infoTypeLevel, IntPtr info)
 {
     return(ChangeServiceConfig2W(service, infoTypeLevel, info));
 }
Пример #9
0
 bool INativeInterop.DeleteService(ServiceHandle service)
 {
     return(DeleteService(service));
 }
Пример #10
0
 bool INativeInterop.StartServiceW(ServiceHandle service, uint argc, IntPtr wargv)
 {
     return(StartServiceW(service, argc, wargv));
 }
Пример #11
0
 private static void DoUpdateService(string displayName, string description, string binaryPath, Win32ServiceCredentials credentials, bool autoStart, ErrorSeverity errorSeverity, ServiceHandle existingService, ServiceFailureActions serviceFailureActions, bool failureActionsOnNonCrashFailures)
 {
     existingService.ChangeConfig(displayName, binaryPath, ServiceType.Win32OwnProcess,
                                  autoStart ? ServiceStartType.AutoStart : ServiceStartType.StartOnDemand, errorSeverity, credentials);
     existingService.SetDescription(description);
     if (serviceFailureActions != null)
     {
         existingService.SetFailureActions(serviceFailureActions);
         existingService.SetFailureActionFlag(failureActionsOnNonCrashFailures);
     }
     existingService.Start(throwIfAlreadyRunning: false);
 }