QueryServiceConfig2

QueryServiceConfig2

The QueryServiceConfig2 function retrieves the optional configuration parameters of the specified service.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684935(v=vs.85).aspx

<pre style="padding: 5px; margin-top: 0px; margin-bottom: 0px; overflow: auto; word-wrap: normal; font-family: Consolas, Courier, monospace !important; font-size: 14px; line-height: 20px; ">BOOL WINAPI <strong>QueryServiceConfig2</strong>(
  _In_       SC_HANDLE <strong>hService</strong>,
  _In_       DWORD <strong>dwInfoLevel</strong>,
  _Out_opt_  LPBYTE <strong>lpBuffer</strong>,
  _In_       DWORD <strong>cbBufSize</strong>,
  _Out_      LPDWORD <strong>pcbBytesNeeded</strong>
);
 
 
 
Parameters
hService
[in] Handle to the service. This handle is returned by the  OpenService or  CreateService function and must have the SERVICE_QUERY_CONFIG access right. For more information, see  Service Security and Access Rights.
dwInfoLevel
[in] Configuration information to be queried. This parameter can be one of the following values.
ValueMeaning
SERVICE_CONFIG_DESCRIPTION
1
The lpBuffer parameter is a pointer to aSERVICE_DESCRIPTION structure.
SERVICE_CONFIG_FAILURE_ACTIONS
2
The lpBuffer parameter is a pointer to aSERVICE_FAILURE_ACTIONS structure.
lpBuffer
[out] Pointer to the buffer that receives the service configuration information. The format of this data depends on the value of the  dwInfoLevel parameter.

The maximum size of this array is 8K bytes. To determine the required size, specify NULL for this parameter and 0 for the cbBufSize parameter. The function will fail and GetLastError will return ERROR_INSUFFICIENT_BUFFER. The pcbBytesNeeded parameter will receive the required size.

cbBufSize
[in] Size of the structure pointed to by the  lpBuffer parameter, in bytes.
pcbBytesNeeded
[out] Pointer to a variable that receives the number of bytes needed to store the configuration information, if the function fails with ERROR_INSUFFICIENT_BUFFER.
Return Values

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 can be set by the service control manager. Others can 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_QUERY_CONFIG access right.
ERROR_INSUFFICIENT_BUFFERThere is more service configuration information than would fit into thelpBuffer buffer. The number of bytes required to get all the information is returned in the pcbBytesNeeded parameter. Nothing is written to lpBuffer.
ERROR_INVALID_HANDLEThe specified handle is invalid.
Remarks

The QueryServiceConfig2 function returns the optional configuration information stored in the service control manager database for the specified service. You can change this configuration information by using theChangeServiceConfig2 function.

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

Example Code

For an example, see Querying a Service's Configuration.

Requirements
ClientRequires Windows XP or Windows 2000 Professional.
ServerRequires Windows Server 2003 or Windows 2000 Server.
Header

Declared in Winsvc.h; include Windows.h.

Library

Link to Advapi32.lib.

DLLRequires Advapi32.dll.
Unicode

Implemented as QueryServiceConfig2W (Unicode) and QueryServiceConfig2A (ANSI).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值