I use the following code for Enable/Disable windows key in Keyboard.It was working fine .
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();
}
}
}
But If I use the above code it was affect enable/disable after the System getting Restarted.
I need to do with this on Button click from C#.Which means If I call the Disable function from the above code I need to disable windows key Immediately(not affect After Restart).
If I call Enable function from the above code in Button click I need to Enable Windows Key.
How can I do this?? Thanks in Advance !!
MSDN has a page: Disabling Shortcut Keys in Games , which sounds like what you need.
Essentially you install a low-level keyboard hook to eat the undesired keys. You also need to handle the WM_ACTIVATEAPP
message to enable/disable the hook appropriately (otherwise you'll eat the keys when you're not the active application).
Here's an example of installing a low-level keyboard hook from C#.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.