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(); } }
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); }
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);
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 );
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 );
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)); }
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)); }