C++捕捉关闭控制台应用程序事件
来源:互联网 发布:控制上网行为的软件 编辑:程序博客网 时间:2024/05/29 17:54
#include <windows.h> #include <stdio.h> bool ctrlhandler( DWORD fdwctrltype ) { switch( fdwctrltype ) { // handle the ctrl-c signal. case CTRL_C_EVENT: printf( "ctrl-c event\n\n" ); return( true ); // ctrl-close: confirm that the user wants to exit. case CTRL_CLOSE_EVENT: printf( "ctrl-close event\n\n" ); return( true ); // pass other signals to the next handler. case CTRL_BREAK_EVENT: printf( "ctrl-break event\n\n" ); return false; case CTRL_LOGOFF_EVENT: printf( "ctrl-logoff event\n\n" ); return false; case CTRL_SHUTDOWN_EVENT: printf( "ctrl-shutdown event\n\n" ); return false; default: return false; } } void main( void ) { // 控制台添加或删除应用程序处理函数列表; if( SetConsoleCtrlHandler( (PHANDLER_ROUTINE) ctrlhandler, true ) ) { printf( "\nthe control handler is installed.\n" ); printf( "\n -- now try pressing ctrl+c or ctrl+break, or" ); printf( "\n try logging off or closing the console...\n" ); printf( "\n(...waiting in a loop for events...)\n\n" ); while( 1 ){ Sleep(100);} } else printf( "\nerror: could not set control handler"); }
0 0
- C++捕捉关闭控制台应用程序事件
- 控制台应用程序关闭事件
- 如何捕捉控制台程序的关闭事件
- 如何捕捉控制台程序的关闭事件
- 脚本捕捉网页关闭事件
- 捕捉用户关闭浏览器事件
- 捕捉IE关闭按钮事件
- 控制台关闭事件
- 捕捉窗口右上角关闭按钮关闭事件
- 捕捉网页关闭与取消关闭事件
- 捕捉浏览器关闭、刷新事件(a.点击关闭按钮 b.任务栏右击关闭 c.按alt+F4关闭)
- Qt捕捉窗口关闭事件与信号的捕捉
- Qt捕捉窗口关闭事件与信号的捕捉
- Qt捕捉窗口关闭事件与信号的捕捉
- Qt捕捉窗口关闭事件与信号的捕捉
- 关闭按钮点击事件的捕捉
- 关闭按钮点击事件的捕捉
- 关闭按钮点击事件的捕捉
- STM32 USART 输入输出C库函数重定向理解
- emacs常见变量和函数【转载】
- IL思路及遇到的问题、解决方法
- HDU 5458 Stability【树链剖分】
- iar通过Terminal I/O调试
- C++捕捉关闭控制台应用程序事件
- 使用Spring MVC上传图片
- 欢迎使用CSDN-markdown编辑器
- PHP防止SQL注入的方法(1)
- 从XCodeGhost事件看软件来源鉴别的重要性
- 1018:Communication System
- mybatis generator使用
- swift 接口类与实现类
- STM32外设使用要点