Platform SDK: DLLs, Processes, and Threads

QueryServiceConfig2

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

BOOL QueryServiceConfig2(
  SC_HANDLE hService,     // handle to service
  DWORD dwInfoLevel,      // information level
  LPBYTE lpBuffer,        // buffer
  DWORD cbBufSize,        // size of buffer
  LPDWORD pcbBytesNeeded  // bytes needed
);

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.
dwInfoLevel
[in] Specifies the configuration information to query. This parameter can have one of the following values.
Value Meaning
SERVICE_CONFIG_DESCRIPTION The lpBuffer parameter is a pointer to a SERVICE_DESCRIPTION structure.
SERVICE_CONFIG_FAILURE_ACTIONS The lpBuffer parameter is a pointer to a SERVICE_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.
cbBufSize
[in] Specifies the size, in bytes, of the structure pointed to by the lpBuffer parameter.
pcbBytesNeeded
[out] Pointer to a variable that receives the number of bytes needed to return the configuration information, if the function fails with the error 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.

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 the ChangeServiceConfig2 function.

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

Requirements

  Windows NT/2000: Requires Windows 2000.
  Header: Declared in Winsvc.h; include Windows.h.
  Library: Use Advapi32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows 2000.

See Also

Services Overview, Service Functions, ChangeServiceConfig, ChangeServiceConfig2, CreateService, OpenService, QueryServiceConfig, SERVICE_DESCRIPTION, SERVICE_FAILURE_ACTIONS