SC_HANDLE WINAPI CreateService(
_In_ SC_HANDLE hSCManager,
_In_ LPCTSTR lpServiceName,
_In_opt_ LPCTSTR lpDisplayName,
_In_ DWORD dwDesiredAccess,
_In_ DWORD dwServiceType,
_In_ DWORD dwStartType,
_In_ DWORD dwErrorControl,
_In_opt_ LPCTSTR lpBinaryPathName,
_In_opt_ LPCTSTR lpLoadOrderGroup,
_Out_opt_ LPDWORD lpdwTagId,
_In_opt_ LPCTSTR lpDependencies,
_In_opt_ LPCTSTR lpServiceStartName,
_In_opt_ LPCTSTR lpPassword
);
Value | Meaning |
---|---|
|
Reserved. |
|
File system driver service. |
|
Driver service. |
|
Reserved. |
|
Service that runs in its own process. |
|
Service that shares a process with one or more other services. For more information, see Service Programs. |
Value | Meaning |
---|---|
|
The service can interact with the desktop. For more information, see Interactive Services. |
Value | Meaning |
---|---|
|
A service started automatically by the service control manager during system startup. For more information, see Automatically Starting Services. (在系统启动的时候,由SCM自动运行服务) |
|
A device driver started by the system loader. This value is valid only for driver services. (系统引导程序自动运行服务,只对driver services有效) |
|
A service started by the service control manager when a process calls the StartService function. For more information, see Starting Services on Demand. (当一个程序调用StartService函数时,SCM启动服务) |
|
A service that cannot be started. Attempts to start the service result in the error code ERROR_SERVICE_DISABLED. (一个不能启动的服务,尝试启动它时,会产生ERROR_SERVICE_DISABLED) |
|
A device driver started by the IoInitSystem function. This value is valid only for driver services. (一个由 IoInitSystem函数启动的服务) |
Value | Meaning |
---|---|
|
The startup program logs the error in the event log, if possible. If the last-known-good configuration is being started, the startup operation fails. Otherwise, the system is restarted with the last-known good configuration. |
|
The startup program ignores the error and continues the startup operation. |
|
The startup program logs the error in the event log but continues the startup operation. |
|
The startup program logs the error in the event log. If the last-known-good configuration is being started, the startup operation continues. Otherwise, the system is restarted with the last-known-good configuration. |
返回值
|
描述
|
ERROR_ACCESS_DENIED
|
提供的hSCManager参数没有SC_MANAGER_CREATE_SERVICE权限。
|
ERROR_CIRCULAR_DEPENDENCY
|
存在循环嵌套的服务依赖关系。
|
ERROR_DUPLICATE_SERVICE_NAME
|
显示名称已在SCM中被其他服务注册为服务名称或显示名称。
|
ERROR_INVALID_HANDLE
|
提供的hSCManager参数无效。
|
ERROR_INVALID_NAME
|
提供的服务名称无效。
|
ERROR_INVALID_PARAMETER
|
其他参数无效。
|
ERROR_INVALID_SERVICE_ACCOUNT
|
由lpServiceStartName参数指定的用户名不存在。
|
ERROR_SERVICE_EXISTS
|
已存在完全相同的服务。
|
值
|
描述
|
DependOnGroup
|
由lpDependencies参数指定的依赖性服务群组,包含加载顺序。
|
DependOnService
|
由lpDependencies参数指定的依赖性服务。
|
Description
|
由ChangeServiceConfig2函数写入的描述信息。
|
DisplayName
|
由lpDisplayName参数指定的服务显示名称。
|
ErrorControl
|
由dwErrorControl参数指定的纠错方案。
|
FailureActions
|
由ChangeServiceConfig2函数写入的异常信息。
|
Group
|
由lpLoadOrderGroup参数指定的服务群组,包含加载顺序。
|
ImagePath
|
由lpBinaryPathName参数指定的服务程序文件位置。
|
ObjectName
|
由lpServiceStartName参数指定的名称。
|
Start
|
由dwStartType参数指定的服务启动时间。
|
Tag
|
由lpdwTagId参数指定的识别信息。
|
Type
|
由dwServiceType参数指定的服务类型。
|