コード例 #1
0
        /// <summary>
        /// Install on the specified thread
        /// </summary>
        /// <param name="dwThreadId"></param>
        public void Install(uint dwThreadId)
        {
            // create the hook delegate and save a reference to it so that
            // it isn't garbage collected
            m_hookDelegate = new User32.HookDelegate(this.KeyboardProc);

            // install the hook for this thread
            m_hHook = User32.SetWindowsHookEx(
                WH.KEYBOARD, m_hookDelegate, IntPtr.Zero, dwThreadId);
            Trace.Assert(m_hHook != IntPtr.Zero, "Failed to install keyboard-hook!");
        }
コード例 #2
0
        /// <summary>
        /// Install on the specified thread
        /// </summary>
        /// <param name="dwThreadId"></param>
        public void Install(uint dwThreadId)
        {
            // create the hook delegate and save a reference to it so that
            // it isn't garbage collected
            m_hookDelegate = new User32.HookDelegate(this.KeyboardProc);

            // install the hook for this thread
            m_hHook = User32.SetWindowsHookEx(
                WH.KEYBOARD, m_hookDelegate, IntPtr.Zero, dwThreadId);
            Trace.Assert(m_hHook != IntPtr.Zero, "Failed to install keyboard-hook!");
        }