Obtaining HHOOK for CallNextHookEx

This is a discussion on Obtaining HHOOK for CallNextHookEx within the Windows Programming forums, part of the Platform Specific Boards category; In my KeyboardProc in my dll, how can I obtain the handle returned to the hook by SetWindowsHookEx so that ...

  1. #1
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136

    Obtaining HHOOK for CallNextHookEx

    In my KeyboardProc in my dll, how can I obtain the handle returned to the hook by SetWindowsHookEx so that I can call CallNextHookEx?

  2. #2
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    It's passed to your hook function. Read the MSDN.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    huh

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    Oops. My bad. Hook handle is return by SetWindowsHookEx.

    Eg.

    Code:
    LRESULT __stdcall LowLevelKeyboardProc (DWORD code, WPARAM wparam, LPARAM lparam)
    {
       if (code == HC_ACTION) /* A key was pressed */
       {
          KBDLLHOOKSTRUCT *hookstruct = (KBDLLHOOKSTRUCT *)lparam;
          /* Send key to our main program */
          PostMessage (hWnd, WM_U_HOOKMSG, (hookstruct->vkCode << 16) + hookstruct->scanCode, hookstruct->flags);
       }
       /* Otherwise pass it down... */
       return (CallNextHookEx (hookHandle, code, wparam, lparam));
    }
    where the init call is:

    Code:
    hookHandle = SetWindowsHookEx (WH_KEYBOARD_LL, (HOOKPROC)&LowLevelKeyboardProc, HInstance, 0);

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Yeah, my problem was that the proc function was assigned in a dll, separate from the actual hook call. I just ended up using a startup function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Obtaining useful information from Crash Report
    By @nthony in forum Windows Programming
    Replies: 6
    Last Post: 04-07-2009, 09:37 PM
  2. Replies: 21
    Last Post: 09-17-2008, 07:37 AM
  3. Obtaining real types from variants
    By therealwill in forum C++ Programming
    Replies: 6
    Last Post: 05-13-2006, 06:15 AM
  4. obtaining CD info
    By axon in forum Linux Programming
    Replies: 5
    Last Post: 09-22-2004, 09:55 AM
  5. Obtaining directory listings
    By bennyandthejets in forum Windows Programming
    Replies: 6
    Last Post: 06-21-2003, 08:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21