网站首页  词典首页

请输入您要查询的函数:

 

术语 changeserviceconfig
释义 ChangeServiceConfig
语法:
C++
BOOL WINAPI ChangeServiceConfig(
__in SC_HANDLE hService,
__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,
__in_opt LPCTSTR lpDisplayName
);
ChangeServiceConfig功能
改变服务的配置参数。
若要更改可选配置参数,使用ChangeServiceConfig2功能。
参数
hService [in]
句柄的服务。这种处理是由OpenService或CreateService函数返回的,必须有SERVICE_CHANGE_CONFIG访问权限。有关更多信息,请参阅服务安全和访问权限。
dwServiceType [in]
服务的类型。指定SERVICE_NO_CHANGE如果您不改变现有的服务类型,否则,指定以下服务类型之一。
ValueMeaning
SERVICE_FILE_SYSTEM_DRIVER
0x00000002File系统驱动程序服务。
SERVICE_KERNEL_DRIVER
0x00000001Driver服务。
SERVICE_WIN32_OWN_PROCESS
0x00000010Service在其自己的进程中运行。
SERVICE_WIN32_SHARE_PROCESS
0x00000020Service共享一个进程的其他服务。
如果您指定SERVICE_WIN32_OWN_PROCESS或SERVICE_WIN32_SHARE_PROCESS,服务是在LocalSystem帐户的上下文中运行,还可以指定以下类型。
ValueMeaning
SERVICE_INTERACTIVE_PROCESS
0x00000100The服务可以与桌面交互。
有关更多信息,请参阅互动服务。
dwStartType [in]
该服务启动选项。指定SERVICE_NO_CHANGE如果您不改变现行的启动类型,否则,指定下列值之一。
ValueMeaning
SERVICE_AUTO_START
0x00000002A服务启动的服务控制管理器会自动在系统启动。
SERVICE_BOOT_START
0x00000000A设备驱动程序开始由系统加载器。此值只适用于驱动程序服务。
SERVICE_DEMAND_START
0x00000003A服务启动的服务控制管理器当进程调用StartService函数。
SERVICE_DISABLED
0x00000004A服务不能启动。尝试启动的错误代码,服务结果ERROR_SERVICE_DISABLED。
SERVICE_SYSTEM_START
0x00000001A设备驱动程序开始的IoInitSystem功能。此值只适用于驱动程序服务。
dwErrorControl [in]
错误的严重性,和采取的行动,如果此服务无法启动。指定SERVICE_NO_CHANGE如果您不改变现行的错误控制,否则,指定下列值之一。
ValueMeaning
SERVICE_ERROR_CRITICAL
0x00000003The启动程序记录在事件日志中的错误,如果可能的话。如果最后的有效配置正在启动,启动操作失败。否则,在系统重新启动的最后一次正确的配置。
SERVICE_ERROR_IGNORE
0x00000000The启动程序将忽略该错误并继续启动运作。
SERVICE_ERROR_NORMAL
0x00000001The启动程序记录在事件日志中的错误,但仍启动运作。
SERVICE_ERROR_SEVERE
0x00000002The启动程序记录在事件日志中的错误。如果最后的有效配置正在启动,启动行动仍在继续。否则,在系统重新启动与上次已知的有效配置。
lpBinaryPathName [中,可选]
在完全合格的路径服务的二进制文件。指定NULL如果您不改变现有的路径。如果路径中包含空格,必须引用,它是正确的解释。例如,的“D:\\ \\我的共享\\ \\ myservice.exe”应指定为“\\的”D:\\ \\我的共享\\ \\ myservice.exe \\“”。
路径可以还包括自动启动服务的论点。例如,的“D:\\ \\ myshare \\ \\ myservice.exe arg1 arg2”。这些参数被传递给服务入口点(通常的主要功能)。
如果您指定的另一台计算机上的路径,这个比例必须能够访问由本地计算机的计算机帐户,因为这是安全上下文中远程调用中使用。但是,这项规定允许在远程计算机上的任何潜在漏洞影响到本地计算机。因此,最好使用本地文件。
lpLoadOrderGroup [中,可选]
该组的顺序而这项服务是其成员负载的名称。指定NULL如果您不改变现有的组。指定一个空字符串,服务不属于一个小组。
启动程序使用负载订购团体加载在指定的顺序相对于其他群体的服务组织。在订购团体负荷名单载于以下注册表项ServiceGroupOrder值:
HKEY_LOCAL_MACHINE \\系统\\ CurrentControlSet \\控制
lpdwTagId [指出,可选]
一个变量,它接收标记的值是在lpLoadOrderGroup在参数中指定的组独特的指针。指定NULL如果您不改变现有的标记。
您可以使用命令在命令指定一个在下面的注册表项GroupOrderList的值标记为向量组的负载服务启动标记:
HKEY_LOCAL_MACHINE \\系统\\ CurrentControlSet \\控制
标签是唯一的评估,司机的服务,SERVICE_BOOT_START或SERVICE_SYSTEM_START的启动类型。
lpDependencies [中,可选]
一个指针双空结尾的空阵列分隔的服务或订购团体,该系统之前,必须启动此服务负载的名称可以被启动。 (在一组依赖意味着,这项服务可以运行,如果至少一个小组的成员后,尝试启动该组的所有成员上运行。)指定NULL如果您不改变现行的依赖。指定一个空字符串,如果服务没有依赖性。
您必须前缀SC_GROUP_IDENTIFIER组名单,以便他们可以区分服务的名字,因为服务和服务组共享相同的名称空间。
lpServiceStartName [中,可选]
该帐户下运行的服务应的名称。指定NULL如果您不改变现有帐户的名称。如果服务类型是SERVICE_WIN32_OWN_PROCESS,使用域名的形式在一个帐户名\\用户名。该服务进程将身份登录此用户。如果该帐户属于内置域,您可以指定。\\用户名(请注意,相应的C / C + +字符串是“。\\ \\用户名”)。有关更多信息,请参阅服务用户帐户,并在备注部分警告。
一个共享进程可以运行任何用户。
如果服务类型是SERVICE_KERNEL_DRIVER或SERVICE_FILE_SYSTEM_DRIVER,名称是驱动程序对象的名称,该系统使用加载设备驱动程序。指定NULL如果驱动程序是使用默认对象的名称由我创建/ O系统。
一个服务可以配置为使用管理的帐户或虚拟帐户。如果该服务被配置为使用托管服务帐户,该名称是管理服务帐户的名称。如果该服务被配置为使用虚拟账户,指定为NT服务名称\\服务。如需有关管理服务帐户和虚拟帐户的详细信息,请参阅由服务帐户的逐步指南。
Windows Server 2008中,Windows Vista中的Windows Server 2003,和Windows XP/2000:托管服务和虚拟帐户帐户不支持,直到Windows 7和Windows Server 2008 R2的。
lpPassword [中,可选]
到帐户名称的lpServiceStartName参数指定的密码。指定NULL如果您不改变现有的密码。指定一个空字符串如果该帐户没有密码,或者服务的本地服务,是NetworkService,或LocalSystem帐户下运行。有关更多信息,请参阅服务记录表。
如果该帐户的名称由lpServiceStartName参数指定的是一个管理服务帐户或虚拟帐户的名称,该lpPassword参数必须是NULL。
密码被忽略的驱动程序服务。
lpDisplayName [中,可选]
显示名称要使用的应用程序,以确定其用户提供的服务。指定NULL如果您不改变现行的显示名称,否则,这个字符串有256个字符的最大长度。该名称是区分在服务控制管理器保存。显示名称比较总是不区分大小写。
此参数可以指定一个本地化的字符串使用下列格式:
@ [路径\\] dllnamedll文件名,- strID
与标识符strID加载字符串从dllnamedll文件名,路径是可选的。有关更多信息,请参阅RegLoadMUIString。
Windows Server 2003和Windows XP/2000操作系统:本地化字符串之前不支持Windows Vista的。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
下面的错误代码可能被设置由服务控制管理器。其他的错误代码可能被设置的注册表由服务控制管理器调用的函数。
返回codeDescription
ERROR_ACCESS_DENIEDThe处理不具备SERVICE_CHANGE_CONFIG访问权限。
ERROR_CIRCULAR_DEPENDENCYA循环服务依存指定。
ERROR_DUPLICATE_SERVICE_NAMEThe显示名称已存在于服务控制器管理数据库,无论是作为一个服务名称或其他显示名称。
ERROR_INVALID_HANDLEThe指定的句柄无效。
ERROR_INVALID_PARAMETERA参数被指定无效。
ERROR_INVALID_SERVICE_ACCOUNTThe帐户名称不存在,或服务被指定为共享相同的已安装的服务二进制文件,但与帐户名是不一样的安装服务相同。
ERROR_SERVICE_MARKED_FOR_DELETEThe的服务已标记为删除。
备注
该ChangeServiceConfig功能改变为在服务控制管理数据库中指定的服务配置信息。您可以通过使用QueryServiceConfig函数当前的配置信息。
如果配置更改的服务,它运行的lpDisplayName外,所做的更改不会生效,直到服务停止。要更新,而不必重新启动该服务,使用的LsaCallAuthenticationPackage功能的凭据。
安全备注
设置lpServiceStartName参数改变服务的登录帐户。这可能会导致问题。如果您已经注册服务主体名称(SPN),那么,目前登记在错误的帐户。同样,如果您用一个ACE授予访问的服务,但现在授予访问错误的帐户。
实例
有关示例,请参阅更改一个服务的配置。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinsvc.h(头文件:winuser.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode和ANSI namesChangeServiceConfigW(Unicode)和ChangeServiceConfigA(ANSI)的
参见
ChangeServiceConfig2
CreateService
OpenService
QueryServiceConfig
QueryServiceConfig2
Service Accounts Step-by-Step Guide
服务配置
服务函数
StartService
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==ChangeServiceConfig Function
Changes the configuration parameters of a service.
To change the optional configuration parameters, use the ChangeServiceConfig2 function.
Syntax
C++
BOOL WINAPI ChangeServiceConfig(
__in SC_HANDLE hService,
__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,
__in_opt LPCTSTR lpDisplayName
);
Parameters
hService [in]
A handle to the service. This handle is returned by the OpenService or CreateService function and must have the SERVICE_CHANGE_CONFIG access right. For more information, see Service Security and Access Rights .
dwServiceType [in]
The type of service. Specify SERVICE_NO_CHANGE if you are not changing the existing service type; otherwise, specify one of the following service types.
ValueMeaning
SERVICE_FILE_SYSTEM_DRIVER
0x00000002File system driver service.
SERVICE_KERNEL_DRIVER
0x00000001Driver service.
SERVICE_WIN32_OWN_PROCESS
0x00000010Service that runs in its own process.
SERVICE_WIN32_SHARE_PROCESS
0x00000020Service that shares a process with other services.

If you specify either SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, and the service is running in the context of the LocalSystem account , you can also specify the following type.
ValueMeaning
SERVICE_INTERACTIVE_PROCESS
0x00000100The service can interact with the desktop.
For more information, see Interactive Services .

dwStartType [in]
The service start options. Specify SERVICE_NO_CHANGE if you are not changing the existing start type; otherwise, specify one of the following values.
ValueMeaning
SERVICE_AUTO_START
0x00000002A service started automatically by the service control manager during system startup.
SERVICE_BOOT_START
0x00000000A device driver started by the system loader. This value is valid only for driver services.
SERVICE_DEMAND_START
0x00000003A service started by the service control manager when a process calls the StartService function.
SERVICE_DISABLED
0x00000004A service that cannot be started. Attempts to start the service result in the error code ERROR_SERVICE_DISABLED.
SERVICE_SYSTEM_START
0x00000001A device driver started by the IoInitSystem function. This value is valid only for driver services.

dwErrorControl [in]
The severity of the error, and action taken, if this service fails to start. Specify SERVICE_NO_CHANGE if you are not changing the existing error control; otherwise, specify one of the following values.
ValueMeaning
SERVICE_ERROR_CRITICAL
0x00000003The 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.
SERVICE_ERROR_IGNORE
0x00000000The startup program ignores the error and continues the startup operation.
SERVICE_ERROR_NORMAL
0x00000001The startup program logs the error in the event log but continues the startup operation.
SERVICE_ERROR_SEVERE
0x00000002The 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.

lpBinaryPathName [in, optional]
The fully-qualified path to the service binary file. Specify NULL if you are not changing the existing path. If the path contains a space, it must be quoted so that it is correctly interpreted. For example, "d:\\\\my share\\\\myservice.exe" should be specified as "\\"d:\\\\my share\\\\myservice.exe\\"".
The path can also include arguments for an auto-start service. For example, "d:\\\\myshare\\\\myservice.exe arg1 arg2". These arguments are passed to the service entry point (typically the main function).
If you specify a path on another computer, the share must be accessible by the computer account of the local computer because this is the security context used in the remote call. However, this requirement allows any potential vulnerabilities in the remote computer to affect the local computer. Therefore, it is best to use a local file.
lpLoadOrderGroup [in, optional]
The name of the load ordering group of which this service is a member. Specify NULL if you are not changing the existing group. Specify an empty string if the service does not belong to a group.
The startup program uses load ordering groups to load groups of services in a specified order with respect to the other groups. The list of load ordering groups is contained in the ServiceGroupOrder value of the following registry key:
HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control
lpdwTagId [out, optional]
A pointer to a variable that receives a tag value that is unique in the group specified in the lpLoadOrderGroup parameter. Specify NULL if you are not changing the existing tag.
You can use a tag for ordering service startup within a load ordering group by specifying a tag order vector in the GroupOrderList value of the following registry key:
HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control
Tags are only evaluated for driver services that have SERVICE_BOOT_START or SERVICE_SYSTEM_START start types.
lpDependencies [in, optional]
A pointer to a double null-terminated array of null-separated names of services or load ordering groups that the system must start before this service can be started. (Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group.) Specify NULL if you are not changing the existing dependencies. Specify an empty string if the service has no dependencies.
You must prefix group names with SC_GROUP_IDENTIFIER so that they can be distinguished from a service name, because services and service groups share the same name space.
lpServiceStartName [in, optional]
The name of the account under which the service should run. Specify NULL if you are not changing the existing account name. If the service type is SERVICE_WIN32_OWN_PROCESS, use an account name in the form DomainName\\UserName. The service process will be logged on as this user. If the account belongs to the built-in domain, you can specify .\\UserName (note that the corresponding C/C++ string is ".\\\\UserName"). For more information, see Service User Accounts and the warning in the Remarks section.
A shared process can run as any user.
If the service type is SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER, the name is the driver object name that the system uses to load the device driver. Specify NULL if the driver is to use a default object name created by the I/O system.
A service can be configured to use a managed account or a virtual account. If the service is configured to use a managed service account, the name is the managed service account name. If the service is configured to use a virtual account, specify the name as NT SERVICE\\ServiceName. For more information about managed service accounts and virtual accounts, see the Service Accounts Step-by-Step Guide .
Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000: Managed service accounts and virtual accounts are not supported until Windows 7 and Windows Server 2008 R2.
lpPassword [in, optional]
The password to the account name specified by the lpServiceStartName parameter. Specify NULL if you are not changing the existing password. Specify an empty string if the account has no password or if the service runs in the LocalService, NetworkService, or LocalSystem account. For more information, see Service Record List .
If the account name specified by the lpServiceStartName parameter is the name of a managed service account or virtual account name, the lpPassword parameter must be NULL.
Passwords are ignored for driver services.
lpDisplayName [in, optional]
The display name to be used by applications to identify the service for its users. Specify NULL if you are not changing the existing display name; otherwise, this string has a maximum length of 256 characters. The name is case-preserved in the service control manager. Display name comparisons are always case-insensitive.
This parameter can specify a localized string using the following format:
@[path\\]dllname,-strID
The string with identifier strID is loaded from dllname; the path is optional. For more information, see RegLoadMUIString .
Windows Server 2003 and Windows XP/2000: Localized strings are not supported until Windows Vista.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
The following error codes may be set by the service control manager. Other error codes may be set by the registry functions that are called by the service control manager.
Return codeDescription
ERROR_ACCESS_DENIEDThe handle does not have the SERVICE_CHANGE_CONFIG access right.
ERROR_CIRCULAR_DEPENDENCYA circular service dependency was specified.
ERROR_DUPLICATE_SERVICE_NAMEThe display name already exists in the service controller manager database, either as a service name or as another display name.
ERROR_INVALID_HANDLEThe specified handle is invalid.
ERROR_INVALID_PARAMETERA parameter that was specified is invalid.
ERROR_INVALID_SERVICE_ACCOUNTThe account name does not exist, or a service is specified to share the same binary file as an already installed service but with an account name that is not the same as the installed service.
ERROR_SERVICE_MARKED_FOR_DELETEThe service has been marked for deletion.

Remarks
The ChangeServiceConfig function changes the configuration information for the specified service in the service control manager database. You can obtain the current configuration information by using the QueryServiceConfig function.
If the configuration is changed for a service that is running, with the exception of lpDisplayName, the changes do not take effect until the service is stopped. To update the credentials without having to restart the service, use the LsaCallAuthenticationPackage function.
Security Remarks
Setting the lpServiceStartName parameter changes the logon account of the service. This can cause problems. If you have registered a service principal name (SPN), it would now be registered on the wrong account. Similarly, if you have used an ACE to grant access to a service, it would now grant access to the wrong account.
Examples
For an example, see Changing a Service's Configuration .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinsvc.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesChangeServiceConfigW (Unicode) and ChangeServiceConfigA (ANSI)
See Also
ChangeServiceConfig2
CreateService
OpenService
QueryServiceConfig
QueryServiceConfig2
Service Accounts Step-by-Step Guide
Service Configuration
Service Functions
StartService
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms681987(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:22:28