[英]Enable/Disable Windows Key
我在键盘中启用/禁用Windows键使用以下代码。它工作正常。
public static class WindowsKey {
public static void Disable() {
RegistryKey key = null;
try {
key = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Keyboard Layout", true);
byte[] binary = new byte[] {
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x03,
0x00,
0x00,
0x00,
0x00,
0x00,
0x5B,
0xE0,
0x00,
0x00,
0x5C,
0xE0,
0x00,
0x00,
0x00,
0x00
};
key.SetValue("Scancode Map", binary, RegistryValueKind.Binary);
}
catch (System.Exception ex) {
Debug.Assert(false, ex.ToString());
}
finally {
key.Close();
}
}
public static void Enable() {
RegistryKey key = null;
try {
key = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Keyboard Layout", true);
key.DeleteValue("Scancode Map", true);
}
catch (System.Exception ex) {
Debug.Assert(false, ex.ToString());
}
finally {
key.Close();
}
}
}
但是,如果我使用上面的代码,则会在系统重新启动后影响启用/禁用。
我需要使用C#的Button click进行此操作。这意味着,如果我从上述代码中调用Disable函数,则需要立即禁用Windows键(不影响重启后)。
如果我从按钮中的上述代码中调用启用功能,请单击“启用Windows键”。
我怎样才能做到这一点?? 提前致谢 !!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.