ChangeServiceConfig2 function

ChangeServiceConfig2 function

Changes the optional configuration parameters of a service.

Syntax

C++

BOOL WINAPI ChangeServiceConfig2(
  _In_     SC_HANDLE hService,
  _In_     DWORD     dwInfoLevel,
  _In_opt_ LPVOID    lpInfo
);

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.

If the service controller handles the SC_ACTION_RESTART action, hService must have the SERVICE_START access right.

dwInfoLevel [in]

The configuration information to be changed. This parameter can be one of the following values.

Value Meaning
SERVICE_CONFIG_DELAYED_AUTO_START_INFO
3

The lpInfo parameter is a pointer to a SERVICE_DELAYED_AUTO_START_INFO structure.

Windows Server 2003 and Windows XP:  This value is not supported.

SERVICE_CONFIG_DESCRIPTION
1

The lpInfo parameter is a pointer to a SERVICE_DESCRIPTION structure.

SERVICE_CONFIG_FAILURE_ACTIONS
2

The lpInfo parameter is a pointer to a SERVICE_FAILURE_ACTIONS structure.

If the service controller handles the SC_ACTION_REBOOT action, the caller must have the SE_SHUTDOWN_NAMEprivilege. For more information, see Running with Special Privileges.

SERVICE_CONFIG_FAILURE_ACTIONS_FLAG
4

The lpInfo parameter is a pointer to a SERVICE_FAILURE_ACTIONS_FLAG structure.

Windows Server 2003 and Windows XP:  This value is not supported.

SERVICE_CONFIG_PREFERRED_NODE
9

The lpInfo parameter is a pointer to a SERVICE_PREFERRED_NODE_INFO structure.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  This value is not supported.

SERVICE_CONFIG_PRESHUTDOWN_INFO
7

The lpInfo parameter is a pointer to a SERVICE_PRESHUTDOWN_INFO structure.

Windows Server 2003 and Windows XP:  This value is not supported.

SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO
6

The lpInfo parameter is a pointer to a SERVICE_REQUIRED_PRIVILEGES_INFO structure.

Windows Server 2003 and Windows XP:  This value is not supported.

SERVICE_CONFIG_SERVICE_SID_INFO
5

The lpInfo parameter is a pointer to a SERVICE_SID_INFO structure.

SERVICE_CONFIG_TRIGGER_INFO
8

The lpInfo parameter is a pointer to a SERVICE_TRIGGER_INFO structure. This value is not supported by the ANSI version of ChangeServiceConfig2.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  This value is not supported until Windows Server 2008 R2.

SERVICE_CONFIG_LAUNCH_PROTECTED
12

The lpInfo parameter is a pointer a SERVICE_LAUNCH_PROTECTED_INFO structure.

Note  This value is supported starting with Windows 8.1.

lpInfo [in, optional]

A pointer to the new value to be set for the configuration information. The format of this data depends on the value of the dwInfoLevel parameter. If this value is NULL, the information remains unchanged.

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.

Remarks

The ChangeServiceConfig2 function changes the optional configuration information for the specified service in the service control manager database. You can obtain the current optional configuration information by using the QueryServiceConfig2 function.

You cannot set the SERVICE_CONFIG_FAILURE_ACTIONS value for a service that shares the service control manager‘s process. This includes all services whose executable image is "Services.exe".

You can change and query additional configuration information using the ChangeServiceConfig and QueryServiceConfig functions, respectively.

If a service is configured to restart after it finishes with an error, the service control manager queues the restart action to occur after the specified time delay. A queued restart action cannot be canceled. If the service is manually restarted and then stopped before the queued restart action occurs, the service will restart unexpectedly when the time delay elapses. The service must be explicitly disabled to prevent it from restarting.

The SERVICE_CONFIG_LAUNCH_PROTECTED value can be used to launch the service as protected. In order to launch the service as protected, the service must be signed with a special certificate.

SERVICE_CONFIG_LAUNCH_PROTECTED example:

C++

SERVICE_LAUNCH_PROTECTED_INFO Info;
SC_HANDLE hService;

Info.dwLaunchProtected = SERVICE_LAUNCH_PROTECTED_ANTIMALWARE_LIGHT;

hService = CreateService (...);

if (ChangeServiceConfig2(hService,
                        SERVICE_CONFIG_LAUNCH_PROTECTED,
                        &Info) == FALSE)
{
    Result = GetLastError();
}

Examples

For an example, see Changing a Service‘s Configuration.

Requirements


Minimum supported client


Windows XP [desktop apps only]


Minimum supported server


Windows Server 2003 [desktop apps only]


Header

Winsvc.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names


ChangeServiceConfig2W (Unicode) and ChangeServiceConfig2A (ANSI)

See also

ChangeServiceConfig
CreateService
OpenService
QueryServiceConfig
QueryServiceConfig2
QueryServiceDynamicInformation
Service Configuration
Service Functions
SERVICE_DELAYED_AUTO_START_INFO
SERVICE_DESCRIPTION
SERVICE_FAILURE_ACTIONS
SERVICE_FAILURE_ACTIONS_FLAG
SERVICE_PRESHUTDOWN_INFO
SERVICE_REQUIRED_PRIVILEGES_INFO
SERVICE_SID_INFO
时间: 2024-12-28 17:47:22

ChangeServiceConfig2 function的相关文章

Delphi 不使用自带模板创建服务

[delphi] view plain copy <pre name="code" class="delphi">program Project1; uses Windows, WinSvc; const ServiceName: pchar = 'SnowWings Service'; DisplayName: pchar = 'Skysword'; Description: pchar = '雪羽服务器控制台'; var Status:       

通过百度echarts实现数据图表展示功能

现在我们在工作中,在开发中都会或多或少的用到图表统计数据显示给用户.通过图表可以很直观的,直接的将数据呈现出来.这里我就介绍说一下利用百度开源的echarts图表技术实现的具体功能. 1.对于不太理解echarts是个怎样技术的开发者来说,可以到echarts官网进行学习了解,官网有详细的API文档和实例供大家参考学习. 2.以下是我在工作中实现整理出来的实例源码: 公用的支持js文件 echarts.js.echarts.min.js,还有其他的图表需要支持的js文件也可以到官网下载 echa

帮同学做的大一大作业:《我的家乡—郑州》

---恢复内容开始--- 最近在上海上学的一个高中同学让我帮忙,帮她做她们的计算机课程大作业. 由于关系不错我也不好意思拒绝就帮忙做了,因为这个学期刚刚开始接触HTML5和css,所以制作过程中有很多不懂的,而且由于HTML5是选修课,一星期只有一节,所以做这个花费了比较多的时间,这个网站是我制作的第一个网站,比较有纪念意义,所以发在博客上,作为纪念. 通过去做这个作业,我了解到很多课上学不到的东西.因为没有美工,从头到尾,都是我一个人在臆想,刚开始的时候,根本无从下手,我去参考别人做的家乡网站

Adding New Functions to MySQL(User-Defined Function Interface UDF、Native Function)

catalog 1. How to Add New Functions to MySQL 2. Features of the User-Defined Function Interface 3. User-Defined Function 4. UDF Argument Processing 5. UDF Return Values and Error Handling 6. UDF Compiling and Installing 7. Adding a New Native Functio

安装python 第三方库遇到的安装问题 microsoft visual studio c++ 10.0 is required,Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?

问题一: microsoft visual studio c++ 10.0 is required 安装scrapy时候出现需要vc c++ 10,有时安装其他也会有. 解决方法:安装vc 2010,安装过2017无效,安装过程也不一样. 问题二: 安装好,出现Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed? 解决办法: 1.pip install wheel 2. 到http://

[c++] Inline Function

The inline functions are a C++ enhancement feature to increase the execution time of a program. Compiler replace the definition at compile time instead of referring function defination at runtime. NOTE - This is a suggestion to compiler to make the f

js instanceof Object Function

Object.Function是javascript中顶级的两个对象,同时也属于两个顶级的构造器,function Object(){}.function Function(){}.Object.Function为两个独立的预先创建的两个对象.new Object创建一个具有Object特性的新的一个对象,new Function创建一个具有Function特性的一个新对象. Object是一个对象,包含__proto__.prototype属性. Object.__proto__ = func

different between method and function

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Arial; color: #242729 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Arial; color: #242729; background-color: #ffffff } span.s1 { background-color: #ffffff } span.s2 { } A method is on an o

qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method

最近在做一个网络音乐播放器时,由于出现qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method, 而不能播放网络歌曲. 上网搜了半天,都说要在电脑那里安装openssl,然后把C:\OpenSSL-Win64\bin下的libeay32.dll和ssleay32.dll拷贝到D:\Qt\Qt5.4.2\5.4\mingw491_32\bin, 然而并没什么卵用! 我的解决办法是: Qt的这个目