Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Disable ALT Key

Posted on 2004-09-03
3
Medium Priority
?
354 Views
Last Modified: 2010-04-01
Hello all,

Is there a way to disable the ALT key in a console program?  I only want to disable the key from working in the console window, not in all windows.  It will be running on a Win 2K system.

Thanks,
Tony
0
Comment
Question by:fattumsdad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 11986798
Hm, let me put it like that - what do you want to achieve by that? There might be a way doing that differently, using a less stony trail than I can see now doing that...
0
 
LVL 1

Author Comment

by:fattumsdad
ID: 11986864
Actually, I made a mistake in my question...  what I should have said was, the CTRL key.  My mind was on ALT for some reason :)
I want to stop CTRL-C from terminating the application.  
0
 
LVL 86

Accepted Solution

by:
jkr earned 1200 total points
ID: 11990156
>>I want to stop CTRL-C from terminating the application

Oh, then, just use a handler that catches that:

#include <windows.h>
#include <signal.h>
#include <iostream>
using namespace std;

void __cdecl CtrlCHandler ( int nSig) {

 // do nothing
 cout << "CTRL+C has been pressed" << endl;

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

int main () {

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

 while ( true) Sleep ( 100);
}
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question