New: XDA launches forum for app developers. Discuss coding, tools, marketing, and more.
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
michar
Old
#1  
Member - OP
Thanks Meter 0
Posts: 75
Join Date: Dec 2003
Default Using SetWindowsHookEx to hook the hardware keys

Hi,
I'm trying to call SetWindowsHookEx to handle keyboard hooks using the following line:
Code:
SetWindowsHookEx(WH_KEYBOARD_LL, KHook, AfxGetInstanceHandle() , NULL);
But the compiler does not recognize WH_KEYBOARD_LL and SetWindowsHookEx and I can't get the right header file and library file to satisfy him.

I searched all the header files and found no instance of the hook type or the function.
The function itself appreas to be in coredll.lib, but adding it to the link made no diffarence and it still break.

Can anyone help me out here? :shock:
 
DavidGriffiths
Old
#2  
Junior Member
Thanks Meter 0
Posts: 6
Join Date: Mar 2004
SetWindowsHookEx is not documented but does appear to work. I used the normal Win32 documentation (Visual C++ 6).

declarations for Pocket PC:

Code:
#ifndef WH_KEYBOARD_LL

// These definitions are found in pwinuser.h in Platform Builder

#define WH_KEYBOARD_LL 20

extern "C" {

typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);

typedef struct tagKBDLLHOOKSTRUCT
{
    DWORD vkCode;        // virtual key code
    DWORD scanCode;      // scan code    DWORD flags;       // flags
    DWORD flags;         // unused
    DWORD time;          // time stamp for this message
    DWORD dwExtraInfo;   // extra info from the driver or keybd_event
}
KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;

HHOOK
WINAPI
SetWindowsHookExW(
        int idHook,
        HOOKPROC lpfn,
        HINSTANCE hmod,
        DWORD dwThreadId);

#define SetWindowsHookEx  SetWindowsHookExW

BOOL
WINAPI
UnhookWindowsHookEx(
        HHOOK hhk);

LRESULT
WINAPI
CallNextHookEx(
        HHOOK hhk,
        int nCode,
        WPARAM wParam,
        LPARAM lParam);

}

#endif