Block Control+Alt+Delete

后端 未结 14 714
渐次进展
渐次进展 2020-12-03 08:35

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+d

相关标签:
14条回答
  • 2020-12-03 09:11

    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();
      }
      
    0 讨论(0)
  • 2020-12-03 09:12

    You can pre-run the hidden process taskmgr.exe

    ProcessStartInfo psi = new ProcessStartInfo(System.IO.Path.Combine(Environment.SystemDirectory, "taskmgr.exe"));
    psi.RedirectStandardOutput = false;
    psi.WindowStyle = ProcessWindowStyle.Hidden;
    psi.UseShellExecute = true;
    
    processTaskMgr = Process.Start(psi);
    
    0 讨论(0)
  • 2020-12-03 09:12

    As pointed out in the other answers, there is no secure way of accomplishing this without checking each student's computers, because they could always run a VM.

    As an alternative, have you considered burning your app to a LiveCD and requiring students to boot the LiveCD?

    That way, you control their OS as long as they are running your app. Once done, they can reboot and everything's back to normal.

    Of course, students could reboot their laptops inbetween, but that would probably take long enough to be noticed by the supervisors.

    The VM solution would still trick this, so you'd need to make sure everyone really boots from the CD; otherwise I cannot think of any way around this.

    As a bonus, you'll be isolated from any weird OS problems on the student's laptops (maybe some installed Linux or OS X ;-) ) .

    0 讨论(0)
  • 2020-12-03 09:15

    According to the Windows Internal book (4th edition), Ctrl-Alt-Del sequence cannot be intercepted by non-privileged applications. Also, it is said that this particular sequence cannot be intercepted and that the Winlogon process will always receive it (page 529).

    I never tried to do this, however, but I would trust the book :)

    0 讨论(0)
  • 2020-12-03 09:16

    A very dumb solution (which assumes that the machine is dedicated your software) is to remap the Alt key (to nothing).

    Drawbacks:

    • Permanent effect
    • Requires a restart/logoff to activate

    Works on xp, Vista, W7.

    You can use SharpKeys to remap/disable any key.

    For info on what registry key SharpKey changes see this. One can also remap on a per user basis.

    Warning: If you disable the Alt key and login requires you to press Ctrl+Alt+Del than you won't be able to login. :)

    0 讨论(0)
  • 2020-12-03 09:18

    There're three ways of doing it (registry, administrative templates and hooks) described in this article.

    The code is in C++, but it will be easy to port it to C# with P/Invoke.

    0 讨论(0)
提交回复
热议问题