tags:

views:

77

answers:

4

what is the ascii code of windows key? in my c# application I want to lock or disable windows key.

+2  A: 

Sorry, you can use the KeyCode :

    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode != Keys.LWin && e.KeyCode != Keys.RWin)
            MessageBox.Show("Hello " +  e.KeyData.ToString());
    }
Florian
Or `Keys.RWin`.
Oded
Ok, it's fixed. Thank you :)
Florian
its fine but how can i disable windows key?
nectar
You can't just disable a key. Your application only gets key _presses_ and then only if they're intended for you.
MSalters
http://geekswithblogs.net/aghausman/archive/2009/04/26/disable-special-keys-in-win-app-c.aspxI test it and it works fine ;-)
Florian
A: 

I'm fairly sure that they don't have ascii codes, but they do have key codes: VK_LWIN and VK_RWIN for the left and right one.

So for example in Control.KeyDown you'll get a KeyEventArgs that has a KeyCode property which you can compare with Keys.LWin or Keys.RWin.

ho1
A: 

Actually keys like the Windows key don't have an ASCII value. Only keys that are 'printable' have an ASCII value. To detect keys like the Windows key you have to use either the KeyDown or KeyUp events and use the KeyCode to detect which key was pressed.KeyCode for this key is 93.

Ex:-

Private Sub txt_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 93 Then msgbox "93" End If End Sub

gsoni
http://forums.bit-tech.net/showthread.php?t=76247Vitual key codes: http://msdn.microsoft.com/en-us/library/ms645540
NinjaCat
A: 

There isn't an Ascii-Code because the WinKey is not printable. However you can use the virtual key code of these keys as described in the msdn.

tobsen