SetConsoleCtrlHandlerThe SetConsoleCtrlHandler function adds or removes an application-defined HandlerRoutine function from the list of handler functions for the calling process.If no handler function is specified, the function sets an inheritable attribute that determines whether the calling process ignores CTRL+C signals. BOOL SetConsoleCtrlHandler( PHANDLER_ROUTINE HandlerRoutine, BOOL Add );Parameters HandlerRoutine [in] Pointer to the application-defined HandlerRoutine function to add or remove. This parameter can be NULL. Windows Me/98/95: This parameter cannot be NULL. Add [in] If this parameter is TRUE, the handler is added; if it is FALSE, the handler is removed. If the HandlerRoutine parameter is NULL, a TRUE value causes the calling process to ignore CTRL+C input, and a FALSE value restores normal processing of CTRL+C input. This attribute of ignoring or processing CTRL+C is inherited by child processes.MSDN上有例子,我就不贴了.用户关闭或者按CTRL+C,系统退出等等事件你都可以自己收到并处理.
我可以捕获WM_QUERYDESTROY(可能是吧)啊
BOOL SetConsoleCtrlHandler(
PHANDLER_ROUTINE HandlerRoutine,
BOOL Add
);Parameters
HandlerRoutine
[in] Pointer to the application-defined HandlerRoutine function to add or remove. This parameter can be NULL.
Windows Me/98/95: This parameter cannot be NULL.
Add
[in] If this parameter is TRUE, the handler is added; if it is FALSE, the handler is removed.
If the HandlerRoutine parameter is NULL, a TRUE value causes the calling process to ignore CTRL+C input, and a FALSE value restores normal processing of CTRL+C input. This attribute of ignoring or processing CTRL+C is inherited by child processes.MSDN上有例子,我就不贴了.用户关闭或者按CTRL+C,系统退出等等事件你都可以自己收到并处理.