示例#1
0
        public void SetHook(bool enable)
        {
            if (enable && m_hHook == 0)
            {
                m_HookCallback = new WinUtil.HookProc(HookCallbackProc);
                Module module = Assembly.GetExecutingAssembly().GetModules()[0];
                m_hHook = WinUtil.SetWindowsHookEx(WinUtil.WH_KEYBOARD_LL, m_HookCallback, Marshal.GetHINSTANCE(module), 0);
                if (m_hHook == 0)
                {
                    KryptonMessageBox.Show("SetHook Failed. Please make sure the 'Visual Studio Host Process' on the debug setting page is disabled");
                    return;
                }
                return;
            }

            if (enable == false && m_hHook != 0)
            {
                WinUtil.UnhookWindowsHookEx(m_hHook);
                m_hHook = 0;
            }
        }
示例#2
0
        public void SetHook(bool enable)
        {
            if (enable && m_hHook == 0)
            {
                m_HookCallback = new WinUtil.HookProc(HookCallbackProc);
                Module module = Assembly.GetExecutingAssembly().GetModules()[0];
                m_hHook = WinUtil.SetWindowsHookEx(WinUtil.WH_KEYBOARD_LL, m_HookCallback, Marshal.GetHINSTANCE(module),0);
                if (m_hHook == 0)
                {
                    MessageBox.Show("SetHook Failed. Please make sure the 'Visual Studio Host Process' on the debug setting page is disabled");
                    return;
                }
                return;
            }

            if (enable == false && m_hHook != 0)
            {
                WinUtil.UnhookWindowsHookEx(m_hHook);
                m_hHook = 0;
            }
        }
示例#3
0
        public void SetHook(bool enable)
        {
            if (enable && m_hHook == 0)
            {
                m_HookCallback = new WinUtil.HookProc(HookCallbackProc);
                //Module module = Assembly.GetExecutingAssembly().GetModules()[0]; .net 2.0  .net4.0╗рих╗п╩Д░▄
                //m_hHook = WinUtil.SetWindowsHookEx(WinUtil.WH_KEYBOARD_LL, m_HookCallback, Marshal.GetHINSTANCE(module),0);
                IntPtr modulePtr = WinUtil.GetModuleHandle(System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName);
                m_hHook = WinUtil.SetWindowsHookEx(WinUtil.WH_KEYBOARD_LL, m_HookCallback, modulePtr, 0);
                if (m_hHook == 0)
                {
                    MessageBox.Show("SetHook Failed. Please make sure the 'Visual Studio Host Process' on the debug setting page is disabled");
                    return;
                }
                return;
            }

            if (enable == false && m_hHook != 0)
            {
                WinUtil.UnhookWindowsHookEx(m_hHook);
                m_hHook = 0;
            }
        }