/*
This is an example of the SetConsoleCtrlHandler function that is used to install a control handler. When a CTRL+C signal is received, the control handler returns TRUE, indicating that it has handled the signal. Doing this prevents other control handlers from being called. When a CTRL_CLOSE_EVENT signal is received, the control handler returns TRUE, causing the system to display a dialog box that gives the user the choice of terminating the process and closing the console or allowing the process to continue execution. If the user chooses not to terminate the process, the system closes the console when the process finally terminates. When a CTRL+BREAK, CTRL_LOGOFF_EVENT, or CTRL_SHUTDOWN_EVENT signal is received, the control handler returns FALSE. Doing this causes the signal to be passed to the next control handler function. If no other control handlers have been registered or none of the registered handlers returns TRUE, the default handler will be used, resulting in the process being terminated. Note that MyErrorExit is a placeholder for an application-defined function to display and handle error conditions.*/ BOOL CtrlHandler(DWORD fdwCtrlType)
{
switch (fdwCtrlType)
{
// Handle the CTRL+C signal. case CTRL_C_EVENT: Beep(, );
return TRUE; // CTRL+CLOSE: confirm that the user wants to exit. case CTRL_CLOSE_EVENT: return TRUE; // Pass other signals to the next handler. case CTRL_BREAK_EVENT: case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: default: return FALSE;
}
} void main(void)
{
BOOL fSuccess; fSuccess = SetConsoleCtrlHandler(
(PHANDLER_ROUTINE) CtrlHandler, // handler function
TRUE); // add to list
if (! fSuccess)
MyErrorExit("Could not set control handler");
}

最新文章

  1. centos网卡eth1变成eth0修改方法
  2. android 读中文文本文件
  3. Android 查看内存
  4. C# RAS 非对称加密类 支持长字符串
  5. Fragment与Activity交互(使用接口)
  6. SQL设置时间格式
  7. ROS 小乌龟测试
  8. [Vuex] Create a Vuex Store using TypeScript
  9. Asp.net core 学习笔记 2.1 升级到 2.2
  10. ABAP 在被访问的程序中获取访问程序的全局变量
  11. Codeforces 977F - Consecutive Subsequence - [map优化DP]
  12. 每日linux命令学习-grep模式检索
  13. Code Signal_练习题_Knapsack Light
  14. HTTPS-HTTPS原理
  15. [控件] ChangeColorLabel
  16. 理解JavaScript私有作用域
  17. oninput事件(解决onkeyup无法监听到复制黏贴)
  18. 37.ROUND() 函数
  19. 2019.03.19 ZJOI2019模拟赛 解题报告
  20. circusctl命令在ubuntu 上执行,卡住的现象处理。

热门文章

  1. Android菜鸟成长记2-内部类
  2. 济南学习D2T2__数学分析题
  3. An unknown error occurred & “”的 iPhone is busy: Processing symbol files
  4. Codeforces Round #325 垫底纪念
  5. 在WINDOWS上安装oracle database 11
  6. 如何创建多个Memcached服务
  7. git 使用命令总结
  8. 设置EditText光标位置
  9. tar 打包命令
  10. c# 线程信号量 Mutex