如何在C ++窗口中禁用Windows键盘快捷键

时间:2018-06-02 07:55:01

标签: c++ window keyboard-shortcuts

我想禁用键盘快捷键,例如Ctrl + C,Ctrl + V,等等...

我能为此做些什么?

system(/* How to do? */);

1 个答案:

答案 0 :(得分:0)

在C ++(或C中,您告诉我们C ++但您标记了C)CTRL + C快捷方式实际上是SIGINT信号。 SIGINT是一个描述键盘中断的信号(所有信号列表都可以在signal(7)找到。

您可以使用siganl(2)函数(在C / C ++中正常工作)更改默认信号的压缩(如分段错误,浮点异常等...),就像它一样:

#include <signal.h>
#include <stdio.h>

void    sigint_handler(int signum)
{
    (void) signum;
    /* Let this function empty to totally "disable" your signal interpretation */
    /* or just let a printf to see when you pass into */
    printf("Received SIGINT\r\n");
}

void    sigsegv_handler(int signum)
{
    (void) signum;
    /* Let this function empty to totally "disable" your signal interpretation */
    /* or just let a printf to see when you pass into */
    printf("Received SIGINT\r\n");
}

int     main(void)
{
        signal(SIGINT, sigint_handler);
        signal(SIGSEGV, sigsegv_handler);
        /* From now, each time your program will receive a SIGINT */
        /* it will pass into the sigint_handler function and do a printf */
        /* and same for Segfault signal */
        while (1);
        return (0);
}

不确定它是不是你想要的,但我希望我能帮到你。