网站首页  词典首页

请输入您要查询的函数:

 

术语 queryservicestatusex
释义 QueryServiceStatusEx
语法:
C++
BOOL WINAPI QueryServiceStatusEx(
__in SC_HANDLE hService,
__in SC_STATUS_TYPE InfoLevel,
__out_opt LPBYTE lpBuffer,
__in DWORD cbBufSize,
__out LPDWORD pcbBytesNeeded
);
QueryServiceStatusEx功能
检索指定的信息化Level的基础上指定的服务现状。
参数
hService [in]
句柄的服务。这种处理是由CreateService或OpenService函数返回,它必须有SERVICE_QUERY_STATUS访问权限。有关更多信息,请参阅服务安全和访问权限。
InfoLevel [in]
该服务的属性将返回。使用SC_STATUS_PROCESS_INFO检索服务的状态信息。该lpBuffer参数是一个指向SERVICE_STATUS_PROCESS结构的指针。
目前,没有任何其他信息Level的定义。
lpBuffer [指出,可选]
一个缓冲区的接收状态信息的指针。这些数据的格式取决于该InfoLevel参数的值。
这个数组的最大大小为8K字节。要确定所需的大小,指定此参数和cbBufSize参数0空。该函数将失败,而且GetLastError将返回ERROR_INSUFFICIENT_BUFFER。该pcbBytesNeeded参数将获得所需的大小。
cbBufSize [in]
缓冲区的大小指向的lpBuffer参数,以字节为单位。
pcbBytesNeeded [out]
一个变量,它接收所需的所有状态信息存储字节数,如果该函数指针与ERROR_INSUFFICIENT_BUFFER失败。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。下面的错误可以返回。
返回codeDescription
ERROR_INVALID_HANDLEThe句柄无效。
ERROR_ACCESS_DENIEDThe处理不具备SERVICE_QUERY_STATUS访问权限。
ERROR_INSUFFICIENT_BUFFERThe缓冲区太小的SERVICE_STATUS_PROCESS结构。什么也没有写入结构。
ERROR_INVALID_PARAMETERThe的SERVICE_STATUS_PROCESS cbSize成员是无效的。
ERROR_INVALID_LEVELThe InfoLevel参数包含不支持的值。
ERROR_SHUTDOWN_IN_PROGRESSThe系统正在关闭,这个函数不能被调用。
备注
该QueryServiceStatusEx函数返回最新的服务状态信息报告给服务控制管理器。如果该服务只是改变了它的地位,它可能没有更新服务控制管理器还。
进程标识符在SERVICE_STATUS_PROCESS结构返回的是有效的规定,该服务状态是SERVICE_RUNNING,SERVICE_PAUSE_PENDING,SERVICE_PAUSED,或SERVICE_CONTINUE_PENDING之一。如果服务在SERVICE_START_PENDING或SERVICE_STOP_PENDING状态,但是,这一进程标识符可能是无效的,如果服务的SERVICE_STOPPED状态,永远是有效的。
实例
有关示例,请参阅启动的服务或停止服务。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinsvc.h(头文件:winuser.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
参见
服务函数
服务启动
SERVICE_STATUS_PROCESS
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==QueryServiceStatusEx Function
Retrieves the current status of the specified service based on the specified information level.
Syntax
C++
BOOL WINAPI QueryServiceStatusEx(
__in SC_HANDLE hService,
__in SC_STATUS_TYPE InfoLevel,
__out_opt LPBYTE lpBuffer,
__in DWORD cbBufSize,
__out LPDWORD pcbBytesNeeded
);
Parameters
hService [in]
A handle to the service. This handle is returned by the CreateService or OpenService function, and it must have the SERVICE_QUERY_STATUS access right. For more information, see Service Security and Access Rights .
InfoLevel [in]
The service attributes to be returned. Use SC_STATUS_PROCESS_INFO to retrieve the service status information. The lpBuffer parameter is a pointer to a SERVICE_STATUS_PROCESS structure.
Currently, no other information levels are defined.
lpBuffer [out, optional]
A 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 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]
The size of the buffer pointed to by the lpBuffer parameter, in bytes.
pcbBytesNeeded [out]
A pointer to a variable that receives the number of bytes needed to store all status information, if the function fails with ERROR_INSUFFICIENT_BUFFER.
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 errors can be returned.
Return codeDescription
ERROR_INVALID_HANDLEThe handle is invalid.
ERROR_ACCESS_DENIEDThe handle does not have the SERVICE_QUERY_STATUS access right.
ERROR_INSUFFICIENT_BUFFERThe buffer is too small for the SERVICE_STATUS_PROCESS structure. Nothing was written to the structure.
ERROR_INVALID_PARAMETERThe cbSize member of SERVICE_STATUS_PROCESS is not valid.
ERROR_INVALID_LEVELThe InfoLevel parameter contains an unsupported value.
ERROR_SHUTDOWN_IN_PROGRESSThe system is shutting down; this function cannot be called.

Remarks
The QueryServiceStatusEx function returns the most recent service status information reported to the service control manager. If the service just changed its status, it may not have updated the service control manager yet.
The process identifier returned in the SERVICE_STATUS_PROCESS structure is valid provided that the state of the service is one of SERVICE_RUNNING, SERVICE_PAUSE_PENDING, SERVICE_PAUSED, or SERVICE_CONTINUE_PENDING. If the service is in a SERVICE_START_PENDING or SERVICE_STOP_PENDING state, however, the process identifier may not be valid, and if the service is in the SERVICE_STOPPED state, it is never valid.
Examples
For an example, see Starting a Service or Stopping a Service .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinsvc.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
See Also
Service Functions
Service Startup
SERVICE_STATUS_PROCESS
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms684941(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:29:06