EnumServicesStatusEx

EnumServicesStatusEx

The EnumServicesStatusEx function enumerates services in the specified service control manager database. The name and status of each service are provided, along with additional data based on the specified information level.

BOOL EnumServicesStatusEx(
  SC_HANDLE hSCManager,
  SC_ENUM_TYPE InfoLevel,
  DWORD dwServiceType,
  DWORD dwServiceState,
  LPBYTE lpServices,
  DWORD cbBufSize,
  LPDWORD pcbBytesNeeded,
  LPDWORD lpServicesReturned,
  LPDWORD lpResumeHandle,
  LPCTSTR pszGroupName
);
Parameters
hSCManager
[in] Handle to the service control manager database. This handle is returned by the OpenSCManager function, and must have the SC_MANAGER_ENUMERATE_SERVICE access right. For more information, see Service Security and Access Rights.
InfoLevel
[in] Service attributes that are to be returned. Use SC_ENUM_PROCESS_INFO to retrieve the name and service status information for each service in the database. The lpServices parameter is a pointer to a buffer that receives an array of ENUM_SERVICE_STATUS_PROCESS structures. The buffer must be large enough to hold the structures as well as the strings to which their members point.

Currently, no other information levels are defined.

dwServiceType
[in] Type of services to enumerate. This parameter can be one or more of the following values.
ValueMeaning
SERVICE_DRIVER
0x0000000B
Enumerates services of type SERVICE_KERNEL_DRIVER and SERVICE_FILE_SYSTEM_DRIVER.
SERVICE_WIN32
0x00000030
Enumerates services of type SERVICE_WIN32_OWN_PROCESS and SERVICE_WIN32_SHARE_PROCESS.
dwServiceState
[in] State of the services to be enumerated. This parameter can be one of the following values.
ValueMeaning
SERVICE_ACTIVE
0x00000001
Enumerates services that are in the following states: SERVICE_START_PENDING, SERVICE_STOP_PENDING, SERVICE_RUNNING, SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, and SERVICE_PAUSED.
SERVICE_INACTIVE
0x00000002
Enumerates services that are in the SERVICE_STOPPED state.
SERVICE_STATE_ALL
0x00000003
Combines the SERVICE_ACTIVE and SERVICE_INACTIVE states.
lpServices
[out] Pointer to the buffer that receives the status information. The format of this data depends on the value of the InfoLevel parameter.

The maximum size of this array is 64K 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_MORE_DATA. The pcbBytesNeeded parameter will receive the required size.

cbBufSize
[in] Size of the buffer pointed to by the lpServices parameter, in bytes.
pcbBytesNeeded
[out] Pointer to a variable that receives the number of bytes needed to return the remaining service entries, if the buffer is too small.
lpServicesReturned
[out] Pointer to a variable that receives the number of service entries returned.
lpResumeHandle
[in, out] Pointer to a variable that, on input, specifies the starting point of enumeration. You must set this value to zero the first time the EnumServicesStatusEx function is called. On output, this value is zero if the function succeeds. However, if the function returns zero and the GetLastError function returns ERROR_MORE_DATA, this value indicates the next service entry to be read when the EnumServicesStatusEx function is called to retrieve the additional data.
pszGroupName
[in] Load-order group name. If this parameter is a string, the only services enumerated are those that belong to the group that has the name specified by the string. If this parameter is an empty string, only services that do not belong to any group are enumerated. If this parameter is NULL, group membership is ignored and all services are enumerated.
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 errors may be returned.

Return codeDescription
ERROR_ACCESS_DENIEDThe handle does not have the SC_MANAGER_ENUMERATE_SERVICE access right.
ERROR_MORE_DATAThe buffer is too small. Not all data in the active database could be returned. The pcbBytesNeeded parameter contains the number of bytes required to receive the remaining entries.
ERROR_INVALID_PARAMETERAn illegal parameter value was used.
ERROR_INVALID_HANDLEThe handle is invalid.
ERROR_INVALID_LEVELThe InfoLevel parameter contains an unsupported value.
ERROR_SHUTDOWN_IN_PROGRESSThe system is shutting down; this function cannot be called.
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 EnumServicesStatusExW (Unicode) and EnumServicesStatusExA (ANSI).

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值