在delphi中,使用WH_CALLWNDPROC钩子时,钩子回调函数是这样的:
function HookPro(iCode: Integer;wParam: WPARAM;lParam: LPARAM): LRESULT; stdcall; export;我怎样才能从iCode、wParam、lParam三个参数中得到窗口的句柄呢?以及知道系统发给窗口的消息是什么??
谢谢!!

解决方案 »

  1.   

    MSDN:
    The hook procedure can examine the message; it cannot modify it. LRESULT CALLBACK CallWndProc(
      int nCode,      // hook code
      WPARAM wParam,  // current-process flag
      LPARAM lParam   // address of structure with message data
    );
     
    Parameters
    nCode 
    Specifies whether the hook procedure must process the message. If nCode is HC_ACTION, the hook procedure must process the message. If nCode is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and must return the value returned by CallNextHookEx. 
    wParam 
    Specifies whether the message was sent by the current thread. If the message was sent by the current thread, it is nonzero; otherwise, it is zero. 
    lParam 
    Pointer to a CWPSTRUCT structure that contains details about the message. 
      

  2.   

    谢谢beyondtkl(大龙驹<逝追>),不过这是sdk里的说明,我想知道的是在delphi里怎么取得句柄和消息,不同的钩子 wParam、lParam的含义不一样,而且在delphi里wParam、lParam都是integer类型,不知道如和转化成CWPSTRUCT结构
      

  3.   

    lParam是个指针,指向CWPSTRUCT结构的指针
    CWPSTRUCT结构里有句柄和消息:
    typedef struct {
        LPARAM lParam;
        WPARAM wParam;
        UINT message;
        HWND hwnd;
    } CWPSTRUCT, *PCWPSTRUCT;