网站首页  词典首页

请输入您要查询的函数:

 

术语 handlerroutine
释义 HandlerRoutine
语法:
C++
BOOL WINAPI HandlerRoutine(
__in DWORD dwCtrlType
);
HandlerRoutine回调函数
一个应用程序定义的函数与SetConsoleCtrlHandler使用功能。一个控制台进程使用此函数来处理的过程中收到的控制信号。当收到信号时,系统创建一个新线程的过程中执行的功能。
在PHANDLER_ROUTINE类型定义一个指向这个回调函数。 HandlerRoutine是一个应用程序的占位符定义函数的名称。
参数
dwCtrlType [in]
控制类型的信号处理程序收到的。此参数可以是下列值之一。
ValueMeaning
CTRL_C_EVENT
答按Ctrl + C信号的接收,无论是从键盘输入或由GenerateConsoleCtrlEvent函数生成的一个信号。
CTRL_BREAK_EVENT
第1A按Ctrl + Break信号接收,无论是从键盘输入或从GenerateConsoleCtrlEvent产生的一种信号。
CTRL_CLOSE_EVENT
甲信号,该系统发送到所有进程连接到控制台当用户关闭控制台(或者通过单击控制台窗口的窗口菜单,或通过单击结束任务从任务管理器按钮命令关闭)。
CTRL_LOGOFF_EVENT
5A条信号,该系统发送到所有的控制台程序在用户注销。这个信号并不表明该用户注销,所以没有假设可。
请注意,这个信号只有接受的服务。交互式应用程序终止时注销,因此他们不存在时,系统发送这个信号。
CTRL_SHUTDOWN_EVENT
6A条的信号,即系统发送当系统正在关闭。交互式应用程序不存在的时候,系统发出这个信号,因此可以得到的服务只有在这种情况下。服务也有他们自己的关机事件通知机制。有关更多信息,请参阅处理程序。
该信号也可以生成一个使用GenerateConsoleCtrlEvent申请。
返回值
如果该函数处理控制信号,它应该返回TRUE。 If it returns FALSE, the next handler function in the list of handlers for this process is used.
备注
由于该系统创建了一个在这个过程中新的线程来执行处理功能,它有可能处理函数将被另一进程中的线程终止。一定要同步与处理函数的线程进程线程。
每个控制台进程都有其自己的清单HandlerRoutine职能。最初,这个列表只包含一个默认的处理函数调用PRB:ExitProcess期间。一个控制台添加或删除程序通过调用SetConsoleCtrlHandler功能,不影响其他进程处理函数列表的其他处理函数。当一个控制台进程收到任何的控制信号,它的处理功能,被称为最后的注册,第一次所谓的处理程序,直到返回TRUE一个基础。如果没有处理返回TRUE,默认的处理程序被调用。
该CTRL_CLOSE_EVENT,CTRL_LOGOFF_EVENT和CTRL_SHUTDOWN_EVENT信号给进程的一个机会,清理前终止了。阿HandlerRoutine可以执行任何必要的清理,然后执行下列操作之一:
调用ExitProcess函数终止进程。
返回FALSE。如果注册的处理函数没有返回TRUE,默认处理程序终止进程。
返回TRUE。在这种情况下,没有其他处理函数调用,系统会显示一个弹出式对话框,要求用户是否终止该进程。该系统还显示此对话框,如果这个进程不能在一定的时间作出反应期(5秒CTRL_CLOSE_EVENT,和20 CTRL_LOGOFF_EVENT或CTRL_SHUTDOWN_EVENT秒)。
一个进程可以使用SetProcessShutdownParameters功能,以防止在显示注销或关闭一个对话框,用户的系统。在这种情况下,系统的进程终止时HandlerRoutine返回TRUE或超时期间满期。
当一个控制台应用程序作为服务运行,它收到一个修改默认的控制台控制处理程序。此修改处理程序不调用时PRB:ExitProcess期间处理CTRL_LOGOFF_EVENT和CTRL_SHUTDOWN_EVENT信号。这使得服务继续运行后,用户注销。如果服务安装它自己的控制台控制处理,此处理程序之前调用默认处理。如果安装的处理程序调用时PRB:ExitProcess期间处理CTRL_LOGOFF_EVENT信号,服务退出当用户注销。
请注意,第三方库或DLL可以安装一个控制台应用程序的控制处理。如果存在,此处理程序重写默认的处理程序,并且可能导致应用程序退出当用户注销。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWincon.h(头文件:winuser.h)
参见
控制台控制处理程序
控制台函数
PRB:ExitProcess期间
GenerateConsoleCtrlEvent
GetProcessShutdownParameters
SetConsoleCtrlHandler
SetProcessShutdownParameters
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==HandlerRoutine Callback Function
An application-defined function used with the SetConsoleCtrlHandler function. A console process uses this function to handle control signals received by the process. When the signal is received, the system creates a new thread in the process to execute the function.
The PHANDLER_ROUTINE type defines a pointer to this callback function. HandlerRoutine is a placeholder for the application-defined function name.
Syntax
C++
BOOL WINAPI HandlerRoutine(
__in DWORD dwCtrlType
);
Parameters
dwCtrlType [in]
The type of control signal received by the handler. This parameter can be one of the following values.
ValueMeaning
CTRL_C_EVENT
0A CTRL+C signal was received, either from keyboard input or from a signal generated by the GenerateConsoleCtrlEvent function.
CTRL_BREAK_EVENT
1A CTRL+BREAK signal was received, either from keyboard input or from a signal generated by GenerateConsoleCtrlEvent.
CTRL_CLOSE_EVENT
2A signal that the system sends to all processes attached to a console when the user closes the console (either by clicking Close on the console window's window menu, or by clicking the End Task button command from Task Manager).
CTRL_LOGOFF_EVENT
5A signal that the system sends to all console processes when a user is logging off. This signal does not indicate which user is logging off, so no assumptions can be made.
Note that this signal is received only by services. Interactive applications are terminated at logoff, so they are not present when the system sends this signal.
CTRL_SHUTDOWN_EVENT
6A signal that the system sends when the system is shutting down. Interactive applications are not present by the time the system sends this signal, therefore it can be received only be services in this situation. Services also have their own notification mechanism for shutdown events. For more information, see Handler .
This signal can also be generated by an application using GenerateConsoleCtrlEvent.

Return Value
If the function handles the control signal, it should return TRUE. If it returns FALSE, the next handler function in the list of handlers for this process is used.
Remarks
Because the system creates a new thread in the process to execute the handler function, it is possible that the handler function will be terminated by another thread in the process. Be sure to synchronize threads in the process with the thread for the handler function.
Each console process has its own list of HandlerRoutine functions. Initially, this list contains only a default handler function that calls ExitProcess . A console process adds or removes additional handler functions by calling the SetConsoleCtrlHandler function, which does not affect the list of handler functions for other processes. When a console process receives any of the control signals, its handler functions are called on a last-registered, first-called basis until one of the handlers returns TRUE. If none of the handlers returns TRUE, the default handler is called.
The CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT signals give the process an opportunity to clean up before termination. A HandlerRoutine can perform any necessary cleanup, then take one of the following actions:
Call the ExitProcess function to terminate the process.
Return FALSE. If none of the registered handler functions returns TRUE, the default handler terminates the process.
Return TRUE. In this case, no other handler functions are called, and the system displays a pop-up dialog box that asks the user whether to terminate the process. The system also displays this dialog box if the process does not respond within a certain time-out period (5 seconds for CTRL_CLOSE_EVENT, and 20 seconds for CTRL_LOGOFF_EVENT or CTRL_SHUTDOWN_EVENT).
A process can use the SetProcessShutdownParameters function to prevent the system from displaying a dialog box to the user during logoff or shutdown. In this case, the system terminates the process when HandlerRoutine returns TRUE or when the time-out period elapses.
When a console application is run as a service, it receives a modified default console control handler. This modified handler does not call ExitProcess when processing the CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT signals. This allows the service to continue running after the user logs off. If the service installs its own console control handler, this handler is called before the default handler. If the installed handler calls ExitProcess when processing the CTRL_LOGOFF_EVENT signal, the service exits when the user logs off.
Note that a third-party library or DLL can install a console control handler for your application. If it does, this handler overrides the default handler, and can cause the application to exit when the user logs off.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWincon.h (include Windows.h)
See Also
Console Control Handlers
Console Functions
ExitProcess
GenerateConsoleCtrlEvent
GetProcessShutdownParameters
SetConsoleCtrlHandler
SetProcessShutdownParameters
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms683242(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:19:11