コード例 #1
0
        public void ChangeConfig(
            SERVICE_TYPE serviceType,
            SERVICE_START_TYPE startType,
            SERVICE_ERROR_CONTROL errorControl,
            string binaryPathName,
            string loadOrderGroup,
            IntPtr tagId,
            IEnumerable <string> dependencies,
            string serviceStartName,
            string password,
            string displayName)
        {
            var dependenciesString = dependencies == null ? null : string.Join("\0", dependencies) + "\0"; // Collection of strings separated by null and terminated by double null

            if (!NativeMethods.ChangeServiceConfig(
                    handle,
                    (uint)serviceType,
                    (uint)startType,
                    (uint)errorControl,
                    binaryPathName,
                    loadOrderGroup,
                    tagId,
                    dependenciesString,
                    serviceStartName,
                    password,
                    displayName))
            {
                throw new Win32Exception();
            }
        }
コード例 #2
0
            public ServiceHandle CreateService(string name, string displayName,
                SERVICE_TYPE type, SERVICE_START_TYPE startType, SERVICE_ERROR_CONTROL errorControl,
                string binaryPath, string group, string accountName, string password)
            {
                int service;

                if ((service = Win32.CreateService(this, name, displayName, SERVICE_RIGHTS.SERVICE_ALL_ACCESS,
                    type, startType, errorControl, binaryPath, group, 0, 0, accountName, password)) == 0)
                    ThrowLastWin32Error();

                return new ServiceHandle(service, true);
            }
コード例 #3
0
ファイル: NativeMethods.cs プロジェクト: narekye/win-tools
 public static extern ServiceControlHandle CreateService(ServiceControlHandle serviceControlManagerHandler,
                                                         string lpSvcName,
                                                         string lpDisplayName,
                                                         SERVICE_ACCESS dwDesiredAccess,
                                                         SERVICE_TYPES dwServiceType,
                                                         SERVICE_START_TYPES dwStartType,
                                                         SERVICE_ERROR_CONTROL dwErrorControl,
                                                         string lpPathName,
                                                         string lpLoadOrderGroup,
                                                         IntPtr lpdwTagId,
                                                         string lpDependencies,
                                                         string lpServiceStartName,
                                                         string lpPassword);
コード例 #4
0
 public static extern bool ChangeServiceConfig(
     int Service,
     SERVICE_TYPE ServiceType,
     SERVICE_START_TYPE StartType,
     SERVICE_ERROR_CONTROL ErrorControl,
     string BinaryPath,
     string LoadOrderGroup,
     int TagID,
     int Dependencies,
     string StartName,
     string Password,
     string DisplayName
     );
コード例 #5
0
 public static extern int CreateService(int SCManager,
                                        string ServiceName,
                                        string DisplayName,
                                        SERVICE_RIGHTS DesiredAccess,
                                        SERVICE_TYPE ServiceType,
                                        SERVICE_START_TYPE StartType,
                                        SERVICE_ERROR_CONTROL ErrorControl,
                                        string BinaryPathName,
                                        string LoadOrderGroup,
                                        int TagID,
                                        int Dependencies,
                                        string ServiceStartName,
                                        string Password
                                        );
コード例 #6
0
        public IService CreateService(
            string serviceName,
            string displayName,
            SERVICE_ACCESS desiredAccess,
            SERVICE_TYPE serviceType,
            SERVICE_START_TYPE startType,
            SERVICE_ERROR_CONTROL errorControl,
            string binaryPathName,
            string loadOrderGroup,
            IntPtr tagId,
            ICollection <string> dependencies,
            string serviceStartName,
            string password)
        {
            string deps = (dependencies?.Any() ?? false) ? string.Join("\0", dependencies) : null;

            var serviceHandle = NativeMethods.CreateService(
                handle,
                serviceName,
                displayName,
                (uint)desiredAccess,
                (uint)serviceType,
                (uint)startType,
                (uint)errorControl,
                binaryPathName,
                loadOrderGroup,
                tagId,
                deps,
                serviceStartName,
                password
                );

            if (serviceHandle == IntPtr.Zero)
            {
                throw new Win32Exception();
            }

            return(new Service(serviceHandle));
        }
コード例 #7
0
ファイル: Functions.cs プロジェクト: andyvand/ProcessHacker
 public static extern int CreateService(int SCManager,
     string ServiceName,
     string DisplayName,
     SERVICE_RIGHTS DesiredAccess, 
     SERVICE_TYPE ServiceType,
     SERVICE_START_TYPE StartType,
     SERVICE_ERROR_CONTROL ErrorControl,
     string BinaryPathName,
     string LoadOrderGroup,
     int TagID, 
     int Dependencies,
     string ServiceStartName,
     string Password
     );
コード例 #8
0
ファイル: Functions.cs プロジェクト: andyvand/ProcessHacker
 public static extern bool ChangeServiceConfig(
     int Service,
     SERVICE_TYPE ServiceType, 
     SERVICE_START_TYPE StartType,
     SERVICE_ERROR_CONTROL ErrorControl, 
     string BinaryPath, 
     string LoadOrderGroup,
     int TagID, 
     int Dependencies,
     string StartName,
     string Password,
     string DisplayName
     );
コード例 #9
0
            public ServiceHandle CreateService(string name, string displayName,
                                               SERVICE_TYPE type, SERVICE_START_TYPE startType, SERVICE_ERROR_CONTROL errorControl,
                                               string binaryPath, string group, string accountName, string password)
            {
                int service;

                if ((service = Win32.CreateService(this, name, displayName, SERVICE_RIGHTS.SERVICE_ALL_ACCESS,
                                                   type, startType, errorControl, binaryPath, group, 0, 0, accountName, password)) == 0)
                {
                    ThrowLastWin32Error();
                }

                return(new ServiceHandle(service, true));
            }