Invoking a .exe referenced to the c# windows application
<p>I created sample project to disable the keyboard shortcuts of windows.
Then i included the .exe of this sample project to the reference of my
main project where i want to implement this feature.</p>

<p>Problem is, it is not working in my main porject. But working perfectly
in my sample project.</p>

<p>Am i missing something like invoking the referenced .exe ??</p>

<p>I dont want to implement the code of sample project to the main project
i just want to reference the .exe to the main project.</p>

<p>HOW ?</p>

<p>Thanks.</p>

<p>namespace BlockShortcuts</p>

<p>{</p>

<pre><code>public class DisableKeys

{
</code></pre>

<p>private delegate int LowLevelKeyboardProcDelegate(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);</p>

<pre><code>    [DllImport("user32.dll", EntryPoint = "SetWindowsHookExA", CharSet = CharSet.Ansi)]

    private static extern int SetWindowsHookEx(int idHook, LowLevelKeyboardProcDelegate lpfn, int hMod, int dwThreadId);

    [DllImport("user32.dll")]
</code></pre>

<p>private static extern int UnhookWindowsHookEx(int hHook);</p>

<pre><code>    [DllImport("user32.dll", EntryPoint = "CallNextHookEx", CharSet = CharSet.Ansi)]

    private static extern int CallNextHookEx(int hHook, int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);

    const int WH_KEYBOARD_LL = 13;

    private int intLLKey;

    private struct KBDLLHOOKSTRUCT
    {
        public int vkCode;
        int scanCode;
        public int flags;
        int time;
        int dwExtraInfo;
    }
    private int LowLevelKeyboardProc(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam)
    {
        bool blnEat = false; switch (wParam)
        {
            case 256:
            case 257:
            case 260:
            case 261:
                //Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key                           
                if (((lParam.vkCode == 9) &amp;&amp; (lParam.flags == 32)) ||
                    ((lParam.vkCode == 27) &amp;&amp; (lParam.flags == 32)) ||
                    ((lParam.vkCode == 27) &amp;&amp; (lParam.flags == 0)) ||
                    ((lParam.vkCode == 91) &amp;&amp; (lParam.flags == 1)) ||
                    ((lParam.vkCode == 92) &amp;&amp; (lParam.flags == 1)) ||
                    ((true) &amp;&amp; (lParam.flags == 32)))
                {
                    blnEat = true;
                }
                break;
        } if (blnEat) return 1; else return CallNextHookEx(0, nCode, wParam, ref lParam);
    }
    public void DisableKeyboardHook()
    {
        intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, new LowLevelKeyboardProcDelegate(LowLevelKeyboardProc), System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(), 0);
    }
    private void ReleaseKeyboardHook()
    {
        intLLKey = UnhookWindowsHookEx(intLLKey);
    }
    #endregion  
}
</code></pre>

<p>}</p>
