博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
简单的触发黑名单阻断演示 control+c
阅读量:4694 次
发布时间:2019-06-09

本文共 950 字,大约阅读时间需要 3 分钟。

#include "stdafx.h"

#include <signal.h>
#include <windows.h>
#include <iostream>

using namespace std;

void cs(int n)

{
  if(n==SIGINT) {
    cout<<"\n你触发了黑名单"<<endl;
    signal(SIGINT, cs);
    return;
  }
  if(n==SIGBREAK){
    cout<<"\n你按下了ctrl+break,现在退出程序\n";
    exit(0);
  }
}

int main()
{
  char ch[30];
  char* str[3];
  bool flag=false;
  signal(SIGINT, cs); /*注册ctrl+c信号捕获函数*/
  signal(SIGBREAK,cs); /*注册ctrl+break信号捕获函数*/
//黑名单命令
  str[0]="cd";
  str[1]="ls";
  str[2]="dir";
  

  while(1)

    if(flag!=true){

      cin>>ch;

      for(int i=0;i<sizeof(str)/sizeof(str[0]);i++){
        if(strcmp(ch,str[i])==0){

           //组合按键

           keybd_event(VK_CONTROL,0,0,0);   //按下control键
           keybd_event(67,0,0,0);                  //按下C键
           keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
           keybd_event(67,0,KEYEVENTF_KEYUP,0);
          flag=true;
        }
      }
    }
  }

return 0;

}

转载于:https://www.cnblogs.com/duyy/p/3662326.html

你可能感兴趣的文章
9结构型模式之代理模式
查看>>
第二节 整型数据
查看>>
Python 序列
查看>>
Liferay的架构:缓存(第一部分)
查看>>
初识B/S结构编程技术
查看>>
方法、hadoop源码之JobQueueTaskScheduler-by小雨
查看>>
页面重构总结
查看>>
IO 函数
查看>>
Unity V3 初步使用 —— 为我的.NET项目从简单三层架构转到IOC做准备
查看>>
JSP页面间传递参数
查看>>
VSNETcodePrint 2005 & SQL ServerPrint 2005
查看>>
java数组基本操作
查看>>
String的indexOf()用于获取字符串中某个子字符串的位置
查看>>
shell 脚本运算符
查看>>
又一道软通动力7K月薪面试题——银行业务调度系统
查看>>
Matlab画图-非常具体,非常全面
查看>>
ReactJS入门
查看>>
linux网站配置文件.htaccess伪静态转换到IIS web.config中
查看>>
CodeForces 1B
查看>>
win10应用UserControl
查看>>