g_hHook = SetWindowsHookEx(WH_KEYBOARD_LL,LowlevelKeyboardProc,NULL,g_MainHandle);
编译出错 error C2065: 'WH_KEYBOARD_LL' : undeclared identifier     怎么处理?如远程DLL插入成功,要想向被插入进程发送一个按键消息是不是还是要用消息钩子!直接用GetCurrentProcess可以得到被插入进程handle吗?? 按键消息可以直接用PostMessage发送不?

解决方案 »

  1.   

    HHOOK SetWindowsHookEx(
      int idHook,        // type of hook to install
      HOOKPROC lpfn,     // address of hook procedure
      HINSTANCE hMod,    // handle to application instance
      DWORD dwThreadId   // identity of thread to install hook for
    );
    1.
    WH_KEYBOARD_LL  
    Windows NT: Installs a hook procedure that monitors low-level keyboard input events. For more information, see the LowLevelKeyboardProc hook procedure. MSDN上好象说是用在Windows NT上的,你可以试一下WH_KEYBOARD.2.
    在HOOKPROC函数中得到你要处理的窗体的HWND,然后发送你的消息,可以使用PostMessage或SendMessage.
    PostMessage把消息发送出去不管成功与否,立即返回.
    SendMessage把消息成功发送出去后,程序才往下面走.
      

  2.   

    #include "winuser.h" 且需要
    #if (_WIN32_WINNT >= 0x0400)
    才有定义nt4 sp3以上支持