title: I can't disable Windows Key with C#
body: <p>I use Windows 8 . I try to disable Windows Key with c# like this example <a href="http://tamas.io/c-disable-ctrl-alt-del-alt-tab-alt-f4-start-menu-and-so-on/" rel="nofollow">http://tamas.io/c-disable-ctrl-alt-del-alt-tab-alt-f4-start-menu-and-so-on/</a> . It have no error but the Windows Key was not disable. How to disable Windows Key with C# ? </p>
  
  <p>This is my code. </p>
  
  <pre><code>namespace TestDisable
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          [DllImport("user32", EntryPoint = "SetWindowsHookExA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
          public static extern int SetWindowsHookEx(int idHook, LowLevelKeyboardProcDelegate lpfn, int hMod, int dwThreadId);
          [DllImport("user32", EntryPoint = "UnhookWindowsHookEx", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
          public static extern int UnhookWindowsHookEx(int hHook);
          public delegate int LowLevelKeyboardProcDelegate(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);
          [DllImport("user32", EntryPoint = "CallNextHookEx", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
          public static extern int CallNextHookEx(int hHook, int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);
          public const int WH_KEYBOARD_LL = 13;
  
          /*code needed to disable start menu*/
          [DllImport("user32.dll")]
          private static extern int FindWindow(string className, string windowText);
          [DllImport("user32.dll")]
          private static extern int ShowWindow(int hwnd, int command);
  
          private const int SW_HIDE = 0;
          private const int SW_SHOW = 1;
  
          public struct KBDLLHOOKSTRUCT
          {
              public int vkCode;
              public int scanCode;
              public int flags;
              public int time;
              public int dwExtraInfo;
          }
  
          public static int intLLKey;
  
          public int LowLevelKeyboardProc(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam)
          {
              bool blnEat = false;
  
                         try
          {
              switch (wParam)
              {
                  case 256:
                  case 257:
                  case 260:
                  case 261:
  
                      //Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key,
                      blnEat = ((lParam.vkCode == 9) &amp;&amp; (lParam.flags == 32))  // alt+tab
                          | ((lParam.vkCode == 27) &amp;&amp; (lParam.flags == 32)) // alt+esc
                          | ((lParam.vkCode == 27) &amp;&amp; (lParam.flags == 0))  // ctrl+esc
                          | ((lParam.vkCode == 91) &amp;&amp; (lParam.flags == 1))  // left winkey
                          | ((lParam.vkCode == 92) &amp;&amp; (lParam.flags == 1))
                          | ((lParam.vkCode == 73) &amp;&amp; (lParam.flags == 0));
  
                      break;
              }
  
  
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
  
              if (blnEat == true)
              {
                  return 1;
              }
              else
              {
                  return CallNextHookEx(0, nCode, wParam, ref lParam);
              }
          }
  
           private void Form1_Load(object sender, EventArgs e)
      {
          try
          {
          intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(), 0);
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          try
          {
              intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(), 0);
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
      }
  }
  </code></pre>