When building a full-screen application, blocking shortcuts like Alt+F4, Win+Tab, and Alt+Tab is often only part of the job. Task Manager is another escape route that usually needs to be handled.
After looking into it, one thing becomes clear: Ctrl+Alt+Del operates at a Ring 0 level, so it is extremely difficult to suppress. A simple hook is not enough to make it ineffective. In practice, the most straightforward approach is to enable or disable Task Manager through the Windows registry.
The relevant registry path is:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System
Under this key, the DisableTaskmgr value controls whether Task Manager is available. Its type is REG_DWORD:
1: disable Task Manager0: enable Task Manager
The change takes effect immediately after modification.
In Rust, the winreg crate provides a convenient way to work with the registry. A minimal example looks like this:
extern crate winreg;
use std::path::Path;
use winreg::RegKey;
use winreg::enums::*;
fn main() {
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let path = Path::new("Software\\Microsoft\\Windows\\CurrentVersion\\Policies").join("System");
let key = hkcu.create_subkey(&path).unwrap();
key.set_value("DisableTaskmgr", &1u32).unwrap();
let sz_val: String = key.get_value("DisableTaskmgr").unwrap();
println!("DisableTaskmgr = {}", sz_val);
}
Running this code will disable Task Manager. If you change &1u32 to &0u32, Task Manager will be enabled again.
This method avoids trying to intercept Ctrl+Alt+Del directly and is much simpler when the goal is only to control Task Manager access for the current user.