Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Block Control+Alt+Delete

Tags:

c#

.net

I am doing an Online Quiz project in C#. The test client is a Windows Desktop Application running on Windows XP. I need to block the control+alt+delete key combination to prevent students from minimizing/closing the application.

Using PInvoke is okay for me.

I know this is definitely possible because I have seen three applications doing this. They are all proprietary, so I have no way of knowing how it was done.

like image 943
BlueSilver Avatar asked Nov 02 '09 08:11

BlueSilver


People also ask

How do I lock Ctrl Alt Delete on my computer?

Using the Keyboard: Press Ctrl, Alt and Del at the same time. Then, select Lock this computer from the options that appear on the screen.

How do I lock my screen without Ctrl Alt Delete?

Hit the Windows key and the L key on your keyboard. Keyboard shortcut for the lock!


1 Answers

I achieved a similar goal, but with a different tactic in a Time Tracker tool I whipped up. This will give you a form which takes over the screen - doesn't allow windows to appear on top of it and will shoot down task manager if it is started.

  1. Set your form TopMost = True.
  2. override the Form.OnLoad method like so:

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.Location = SystemInformation.VirtualScreen.Location;
        this.Size = SystemInformation.VirtualScreen.Size;
    }
    
  3. Create a timer, with a 500 millisecond interval, which looks for, and kills "taskmgr.exe" and "procexp.exe".

  4. Override the Form.OnFormClosing:

    protected override void OnFormClosing(FormClosingEventArgs e)
    {
        if (e.CloseReason == CloseReason.UserClosing || e.CloseReason == CloseReason.FormOwnerClosing)
        {
            MessageBox.Show("Nice try, but I don't think so...");
            e.Cancel = true;
            return;
        }
        base.OnFormClosing(e);
    }
    
  5. Override OnSizeChanged:

    protected override void OnSizeChanged(EventArgs e) {
        base.OnSizeChanged(e);
        this.WindowState = FormWindowState.Normal;
        this.Location = SystemInformation.VirtualScreen.Location;
        this.Size = SystemInformation.VirtualScreen.Size;
        this.BringToFront();
    }
    
like image 63
Philip Wallace Avatar answered Sep 20 '22 02:09

Philip Wallace