Solved

Disable ALT Key

Posted on 2004-09-03
3
337 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 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

733 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