How can i disable or lock windows button?
+1
A:
Take a look here for some sample code http://tamaspiros.co.uk/2007/12/20/c-disable-ctrl-alt-del-alt-tab-alt-f4-start-menu-and-so-on/
JLWarlow
2010-07-29 09:44:23
+2
A:
You need a keyboard hook. Starts somewhere like this:
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, hInstance, 0);
and continue like this:
LRESULT KeyboardProc(...)
{
if (Key == VK_SOMEKEY)
return 1; // Trap key
return CallNextHookEx(...); // Let the OS handle it
}
And for more detail: http://www.codeproject.com/KB/winsdk/AntonioWinLock.aspx
Tobiasopdenbrouw
2010-07-29 09:49:36
+1
A:
Assuming that you wish to disable the Windows key permenantly and not just when your code is in focus then you can do so by editing the registry as follows:
To disable: Add a new REG_BINARY value called "Scancode Map" to "HKEY_LOCAL_ MACHINE\System\CurrentControlSet\Control\Keyboard Layout" with a data value of "00000000000000000300000000005BE000005CE000000000"
To enable: Delete the "Scancode Map" value entirely from the registry.
ChrisBD
2010-07-29 09:52:09
+1, thanks for that. I'd not be happy with the guy who wrecked my keyboard though.
Tobiasopdenbrouw
2010-07-29 10:07:55
A:
// *********************************************************************
// [DCOM Productions]
// [Copyright (C) DCOM Productions All rights reserved.]
// >> Courtesy of Dave Anderson, DCOM Productions
// *********************************************************************
/// <summary>
/// Security routines related to the Windows Key on a standard personal computer Keyboard
/// </summary>
public static class WindowsKey {
/// <summary>
/// Disables the Windows Key
/// </summary>
/// <remarks>May require the current user to logoff or restart the system</remarks>
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();
}
}
/// <summary>
/// Enables the Windows Key
/// </summary>
/// <remarks>May require the current user to logoff or restart the system</remarks>
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();
}
}
}
David Anderson
2010-09-02 07:04:40