网站首页  词典首页

请输入您要查询的函数:

 

术语 startservicectrldispatcher
释义 StartServiceCtrlDispatcher
语法:
C++
BOOL WINAPI StartServiceCtrlDispatcher(
__in const SERVICE_TABLE_ENTRY *lpServiceTable
);
StartServiceCtrlDispatcher函数
连接一个服务进程的主线程到服务控制管理器,这会导致线程是服务控制调用进程调度线程。
参数
lpServiceTable [in]
对一个包含为每个服务,可以执行在调用进程进入SERVICE_TABLE_ENTRY结构数组的指针。本表中的最后一项的成员必须有NULL值指定表的末尾。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
下面的错误代码可以设置由服务控制管理器。其他的错误代码可以设置的注册表由服务控制管理器调用的函数。
返回codeDescription
ERROR_FAILED_SERVICE_CONTROLLER_CONNECTThis返回错误,如果该程序正在作为控制台应用程序,而不是作为服务运行。如果该程序将运行作为控制台应用程序用于调试目的,它的结构,这样的服务,特定的代码不调用此错误时返回。
ERROR_INVALID_DATAThe指定调度表中的某些项中不正确的格式。
ERROR_SERVICE_ALREADY_RUNNINGThe进程已经调用StartServiceCtrlDispatcher。每个进程可以调用StartServiceCtrlDispatcher一次。
备注
当服务控制管理器启动一个服务的过程,它等待调用StartServiceCtrlDispatcher函数的过程。一个服务进程的主线程应该使这一呼吁尽快启动后(30秒内)。如果StartServiceCtrlDispatcher成功,它调用线程连接到服务控制管理器,并不会返回,直到所有正在运行的服务的过程中已进入SERVICE_STOPPED状态。服务控制管理器使用此连接,发送控制和服务的启动请求的服务进程的主线程。作为一个主线程调度行为调用适当的HandlerEx函数来处理控制请求,或创建一个新的线程来执行相应的ServiceMain函数当一个新的服务已启动。
该lpServiceTable参数包含每个服务的,可以运行在调用进程项。每个条目指定该服务的ServiceMain函数。对于SERVICE_WIN32_SHARE_PROCESS服务,每个项目必须包含一个服务名称。这个名字是服务名称是由该服务时安装CreateService函数指定。对于SERVICE_WIN32_OWN_PROCESS服务,表中的条目服务的名称将被忽略。
如果一个服务运行在它自己的进程,该服务进程的主线程应立即调用StartServiceCtrlDispatcher。所有的初始化工作做在服务的ServiceMain函数时,该服务已启动。
如果多个服务共享一个过程,一些常见的进程范围初始化之前,需要做任何ServiceMain函数被调用时,主线程可以调用StartServiceCtrlDispatcher前做的工作,只要花不到30秒。否则,另一个线程必须创建这样的进程范围的初始化,而主线程调用StartServiceCtrlDispatcher,成为服务控制调度。任何服务特定的初始化仍然应该做的个人服务的主要职能。
服务不应试图显示用户界面,直接。有关更多信息,请参阅互动服务。
实例
有关示例,请参见编写一个服务程序的主要功能。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinsvc.h(头文件:winuser.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode和ANSI namesStartServiceCtrlDispatcherW(Unicode)和StartServiceCtrlDispatcherA(ANSI)的
参见
ControlService
HandlerEx
服务入口点
服务函数
ServiceMain
SERVICE_TABLE_ENTRY
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==StartServiceCtrlDispatcher Function
Connects the main thread of a service process to the service control manager, which causes the thread to be the service control dispatcher thread for the calling process.
Syntax
C++
BOOL WINAPI StartServiceCtrlDispatcher(
__in const SERVICE_TABLE_ENTRY *lpServiceTable
);
Parameters
lpServiceTable [in]
A pointer to an array of SERVICE_TABLE_ENTRY structures containing one entry for each service that can execute in the calling process. The members of the last entry in the table must have NULL values to designate the end of the table.
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 error code can be set by the service control manager. Other error codes can be set by the registry functions that are called by the service control manager.
Return codeDescription
ERROR_FAILED_SERVICE_CONTROLLER_CONNECTThis error is returned if the program is being run as a console application rather than as a service. If the program will be run as a console application for debugging purposes, structure it such that service-specific code is not called when this error is returned.
ERROR_INVALID_DATAThe specified dispatch table contains entries that are not in the proper format.
ERROR_SERVICE_ALREADY_RUNNINGThe process has already called StartServiceCtrlDispatcher. Each process can call StartServiceCtrlDispatcher only one time.

Remarks
When the service control manager starts a service process, it waits for the process to call the StartServiceCtrlDispatcher function. The main thread of a service process should make this call as soon as possible after it starts up (within 30 seconds). If StartServiceCtrlDispatcher succeeds, it connects the calling thread to the service control manager and does not return until all running services in the process have entered the SERVICE_STOPPED state. The service control manager uses this connection to send control and service start requests to the main thread of the service process. The main thread acts as a dispatcher by invoking the appropriate HandlerEx function to handle control requests, or by creating a new thread to execute the appropriate ServiceMain function when a new service is started.
The lpServiceTable parameter contains an entry for each service that can run in the calling process. Each entry specifies the ServiceMain function for that service. For SERVICE_WIN32_SHARE_PROCESS services, each entry must contain the name of a service. This name is the service name that was specified by the CreateService function when the service was installed. For SERVICE_WIN32_OWN_PROCESS services, the service name in the table entry is ignored.
If a service runs in its own process, the main thread of the service process should immediately call StartServiceCtrlDispatcher. All initialization tasks are done in the service's ServiceMain function when the service is started.
If multiple services share a process and some common process-wide initialization needs to be done before any ServiceMain function is called, the main thread can do the work before calling StartServiceCtrlDispatcher, as long as it takes less than 30 seconds. Otherwise, another thread must be created to do the process-wide initialization, while the main thread calls StartServiceCtrlDispatcher and becomes the service control dispatcher. Any service-specific initialization should still be done in the individual service main functions.
Services should not attempt to display a user interface directly. For more information, see Interactive Services .
Examples
For an example, see Writing a Service Program's Main Function .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinsvc.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesStartServiceCtrlDispatcherW (Unicode) and StartServiceCtrlDispatcherA (ANSI)
See Also
ControlService
HandlerEx
Service Entry Point
Service Functions
ServiceMain
SERVICE_TABLE_ENTRY
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms686324(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 13:24:21