We help IT Professionals succeed at work.

Disable the CTRL+C in a console application

kozmo_jonny
kozmo_jonny asked
on
i need 2 disable the CTRL+C & CTRL+ScrollLock or any other option the user might have (except closing the window !) 2 shut down my application.

i'm using a console application.

i would appreciate source code.

J.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2012
Commented:
CTRL+C is fairly easy, all you have to do is providing your own handler for that signal:

#include <signal.h>

void __cdecl CtrlCHandler ( int nSig) {

  // do nothing
}

// in your code

signal  (   SIGINT,     CtrlCHandler);
signal  (   SIGBREAK,   CtrlCHandler);

alternatively you could just 'ignore' the signal:

// in your code

signal  (   SIGINT,     SIG_IGN);
signal  (   SIGBREAK,   SIG_IGN);


Author

Commented:
10Q... u deserve all the pts.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.