Disable Keyboard Shortcuts and Combination Keys with C# (3): Disable Ctrl + Alt + Del
来源:互联网 发布:阿里云代金券转让 编辑:程序博客网 时间:2024/06/01 18:25
http://www.northcode.com/blog.php/2007/07/25/Securing-Windows-For-Use-As-A-Kiosk
An ingenious method was introduced there. It circumvented the difficulty of developing the keyboard driver. The basic idea is to reset keyboard scan code mapping by modifying Windows registry. The scan code mapping item is stored in the registry at:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\Scancode Map
It's difficult and danger to require common users to modify Windows registry. To develop a specialized program is a better choice. A C# program is given here. Note that the program MUST be run with Administrator Privileges. In order to make it take effect, to restart the computer is necessary.
When it is run, the interface is as follows:
Ctrl key can be disabled or enabled by running the program. Other modifier keys, including WIN and ALT keys are not processed. It's easy to modify the program to disable those keys. When Ctrl key is disabled, all combination keys relating to it, such as Ctrl + Alt + Del and Ctrl + Shift + Esc are also disabled.
Step:
1. Create a C# Windows Forms application in Visual Studio. The project name is 'EnableOrDisableCtrlKey';
2. Switch from code view to designer view, drag a label into the Windows Form from the toolbox. The label text is 'Enable or Disable Ctrl Key?'.
3. Drag three buttons into the Windows Form from the toolbox, named them by EnableButton, DisableButton and ExitButton;
4. Modify the file 'Form1.cs', the source code is as listed below:
/*************************************************** Author: HAN Wei* Author's blog: http://blog.csdn.net/henter/* Date: Dec. 6th, 2016* Description: demonstrate how to disable Ctrl key. Combination keys relating to Ctrl, * such as Ctrl + Alt + Del and Ctrl + Shift + Esc, will also be disabled.**************************************************/using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using Microsoft.Win32;namespace EnableOrDisableCtrlKey{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void EnableButton_Click(object sender, EventArgs e) { RegistryKey rkLm = Registry.LocalMachine; RegistryKey rkLmSys = rkLm.OpenSubKey("SYSTEM"); RegistryKey rkLmSysCcs = rkLmSys.OpenSubKey("CurrentControlSet"); RegistryKey rkLmSysCcsCtrl = rkLmSysCcs.OpenSubKey("Control"); RegistryKey rkLmSysCCsCtrlKl = rkLmSysCcsCtrl.OpenSubKey("Keyboard Layout", true); try { rkLmSysCCsCtrlKl.DeleteValue("Scancode Map", true); } catch (Exception exp) { MessageBox.Show(exp.Message + "\n" + "Ctrl key has been enabled!\nYou don't need to enable it again."); return; } MessageBox.Show("Ctrl key is enabled!\nRestart computer to take effect!"); rkLmSysCCsCtrlKl.Close(); } private void DisableButton_Click(object sender, EventArgs e) { const string keyName = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout"; try { Registry.SetValue(keyName, "Scancode Map", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0, 0, 0, 0, 0, 0x1d, 0, 0, 0, 0x1d, 0xe0, 0, 0, 0, 0 }, RegistryValueKind.Binary); } catch (Exception exp) { MessageBox.Show(exp.Message); return; } MessageBox.Show("Ctrl key is disabled!\nRestart computer to take effect!"); } private void ExitButton_Click(object sender, EventArgs e) { Application.Exit(); } }}
5. Build the program, run it with Administrator Privileges. It is necessary to restart the computer if Ctrl key is enabled or disabled.
- Disable Keyboard Shortcuts and Combination Keys with C# (3): Disable Ctrl + Alt + Del
- Disable Keyboard Shortcuts and Combination Keys with C# (1): Disable frequently used hotkeys
- Disable Keyboard Shortcuts and Combination Keys with C# (2): Disable Win + L
- C# Disable CTRL-ALT-DEL, ALT-TAB, ALT-F4, Start Menu and so on…
- 求教Disable Del+Ctrl+Alt
- C#代码屏蔽CTRL+ALT+DEL
- mysql DISABLE/ENABLE KEYS
- disable thinkpad keyboard NmLk
- keyboard disable search key
- 禁用ctrl+alt+del
- ctrl+alt+del
- 模拟CTRL+ALT+DEL
- 禁用 CTRL+ALT+DEL
- 屏蔽Ctrl+alt+del
- 禁止 CTRL+ALT+DEL
- 禁用Ctrl+alt+del
- C#修改注册表 屏蔽 Ctrl+Alt+Del 键
- Synergy 发送ctrl alt del
- ubuntu 命令
- Extjs MVC模式下传递参数 动态插入Item
- Android textView drawableXX图片大小
- hadoop 端口
- Linux网络编程面试--滑动窗口的实现机制
- Disable Keyboard Shortcuts and Combination Keys with C# (3): Disable Ctrl + Alt + Del
- 在UiAutomator2.0测试脚本中操作联系人数据
- js 双引号中引入变量
- 我的求职之路(一)
- Linux 克隆虚拟机引起的“Device eth0 does not seem to be present, delaying initialization”
- ExtJS之Ext.form.field.Number数字输入框
- Shell中的${}、##和%%使用范例
- Android 混淆代码总结
- 关于Fragment中两个FragmentPagerAdapter和FragmentStatePag的用法 http://www.apkbus.com/Android-90417-1-1.html