网站首页  词典首页

请输入您要查询的函数:

 

术语 registerservicectrlhandlerex
释义 RegisterServiceCtrlHandlerEx
语法:
C++
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
__in LPCTSTR lpServiceName,
__in LPHANDLER_FUNCTION_EX lpHandlerProc,
__in_opt LPVOID lpContext
);
RegisterServiceCtrlHandlerEx功能
注册了一个函数来处理控制请求延长服务。
参数
lpServiceName [in]
这项服务的名称运行调用线程。这是服务名称,服务控制程序在CreateService创建时指定的服务功能。
lpHandlerProc [in]
一个处理函数指针登记。有关更多信息,请参阅HandlerEx。
lpContext [中,可选]
任何用户定义的数据。这个参数,这是传递给处理功能,可以帮助识别服务时,多个服务共享一个进程。
返回值
如果函数成功,返回值是一个服务的状态处理。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
下面的错误代码可以设置由服务控制管理器。
返回codeDescription
ERROR_NOT_ENOUGH_MEMORYNot足够的内存可用的ANSI转换为Unicode字符串参数。此错误不会出现Unicode字符串参数。
ERROR_SERVICE_NOT_IN_EXEThe服务项目被指定的进程时,错误地称为StartServiceCtrlDispatcher函数。
备注
新的服务ServiceMain函数应立即调用RegisterServiceCtrlHandlerEx函数来登记的控制调度控制处理功能。这使得控制调度来调用指定的函数当它接收此项服务的控制要求。对于可能的控制代码的列表,请参阅HandlerEx。调用进程的线程可以使用该服务的状态处理这个函数返回查明SetServiceStatus函数的后续调用的服务。
该RegisterServiceCtrlHandlerEx函数必须在第一次调用SetServiceStatus通话,因为RegisterServiceCtrlHandlerEx返回一个服务的状态为调用句柄使用,因此,没有其他服务就会在不经意间设置此服务的状态。此外,控制处理程序必须到位,这样才能收到的时间内作出服务指定控制它通过SetServiceStatus函数接受控制请求。
当控制处理功能的控制请求调用,服务必须调用SetServiceStatus报告,例如当该服务停止或关闭处理控制地位的服务控制管理器只有在服务的地位发生了变化。如果服务的地位没有改变,该服务不应该报告的地位,服务控制管理器。
服务状态句柄不须予以封闭。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinsvc.h(头文件:winuser.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode和ANSI namesRegisterServiceCtrlHandlerExW(Unicode)和RegisterServiceCtrlHandlerExA(ANSI)的
参见
CreateService
HandlerEx
服务控制处理函数
服务函数
ServiceMain
SetServiceStatus
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==RegisterServiceCtrlHandlerEx Function
Registers a function to handle extended service control requests.
Syntax
C++
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
__in LPCTSTR lpServiceName,
__in LPHANDLER_FUNCTION_EX lpHandlerProc,
__in_opt LPVOID lpContext
);
Parameters
lpServiceName [in]
The name of the service run by the calling thread. This is the service name that the service control program specified in the CreateService function when creating the service.
lpHandlerProc [in]
A pointer to the handler function to be registered. For more information, see HandlerEx .
lpContext [in, optional]
Any user-defined data. This parameter, which is passed to the handler function, can help identify the service when multiple services share a process.
Return Value
If the function succeeds, the return value is a service status handle.
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.
Return codeDescription
ERROR_NOT_ENOUGH_MEMORYNot enough memory is available to convert an ANSI string parameter to Unicode. This error does not occur for Unicode string parameters.
ERROR_SERVICE_NOT_IN_EXEThe service entry was specified incorrectly when the process called the StartServiceCtrlDispatcher function.

Remarks
The ServiceMain function of a new service should immediately call the RegisterServiceCtrlHandlerEx function to register a control handler function with the control dispatcher. This enables the control dispatcher to invoke the specified function when it receives control requests for this service. For a list of possible control codes, see HandlerEx. The threads of the calling process can use the service status handle returned by this function to identify the service in subsequent calls to the SetServiceStatus function.
The RegisterServiceCtrlHandlerEx function must be called before the first SetServiceStatus call because RegisterServiceCtrlHandlerEx returns a service status handle for the caller to use so that no other service can inadvertently set this service status. In addition, the control handler must be in place to receive control requests by the time the service specifies the controls it accepts through the SetServiceStatus function.
When the control handler function is invoked with a control request, the service must call SetServiceStatus to report status to the service control manager only if the service status has changed, such as when the service is processing stop or shutdown controls. If the service status has not changed, the service should not report status to the service control manager.
The service status handle does not have to be closed.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinsvc.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesRegisterServiceCtrlHandlerExW (Unicode) and RegisterServiceCtrlHandlerExA (ANSI)
See Also
CreateService
HandlerEx
Service Control Handler Function
Service Functions
ServiceMain
SetServiceStatus
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms685058(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:26:40