Thread: how to trap Ctrl + Alt + Del

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    21

    how to trap Ctrl + Alt + Del

    I am developing an application which restricts the user to quit the application in un authorized way.

    To do that I need to trap Ctrl+Alt+Del key and Alt + F4 key .

    Can any body suggest me a solution for this

    I tried using WM_SYSCOMMAND to trap, it is working if the focus is on window, but when the focus is on any control of the window,
    I am unable to trap that .

    bye

    vamshi

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    Well, you could monitor the WM_KEYDOWN message & respond to the appropriate keys, but that wouldn't work when your prog doesn't have the keyboard focus.... your only route seems to be a keyboard hook. Hint: it'll need to be in a .dll and will be activated & deactivated by your program. (search this msg board & google)

    -Futura

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    check out this example
    at the codeproject.

  4. #4
    Registered User
    Join Date
    Dec 2002
    Posts
    2

    Trapping Ctrl+Alt+Del

    Windows doesn't allow you to mask these critical system keys. Though you can trap the messages in your application message pump but the same is also sent to Windows System message pump to take required action. You can use Direct X (Direct Input) to mask most of them but for Ctrl + Alt + Del keys there is a trick.
    You have to use an API GetSystemParametersInfo and tell Windows that the screen saver is on so as to ignore the key interrupts. (I did this long back and as far as I remember the flags are SPI_SCREENSAVER and TRUE to indicate the screen saver running). Try this out and have fun.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    Perhaps you can run a second program that monitors if the first is still running. If the first gets cut off it could restart it, and vice versa
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well I think you should drop the idea. There are three things a program can do that I find really annoying.

    1) Lock up windows completely
    2) Make attempts at staying open even though I'm trying to get rid of it.
    3) Interfere with shutdown.

    Any programs that consistently does one of those is history (except for explorer which I'm stuck with). Just because one program revives another does not mean that I still can't get it to go away. But like most people, the more annoying it is to close a program the more likely I am to never use it again.

    [edit]
    Oops, forgot the most important thing, the answer to your question. How about making your program a screen saver?
    [/edit]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ctrl Alt Del
    By cboard_member in forum A Brief History of Cprogramming.com
    Replies: 27
    Last Post: 07-20-2005, 07:36 AM
  2. Grabbing Ctrl and Alt key combinations
    By scorpio_IITR in forum Linux Programming
    Replies: 0
    Last Post: 04-12-2004, 03:01 AM
  3. how to capture CTRL, SHIFT and ALT ?
    By goldenrock in forum C Programming
    Replies: 3
    Last Post: 11-06-2003, 01:20 AM
  4. Trapping Ctrl Alt Delete
    By emus21 in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-17-2003, 12:10 PM
  5. Ctrl + Alt +Delete
    By golfinguy4 in forum Windows Programming
    Replies: 4
    Last Post: 10-27-2002, 07:46 PM