翻了MSDN,上面说可以阻止消息传递给目标窗口,这个怎么弄?还说可以修改消息,我拦截了WM_SETTEXT,修改了消息中的窗口内容的那个参数,显示出来的还是原来的文字,这个怎么改?

解决方案 »

  1.   

    WH_GETMESSAGE可以修改消息,WH_CALLWNDPROC不能修改,通过SendMessage发送的消息都不经过WH_GETMESSAGE,所以都不能修改。
    可以利用钩子将代码注入到目标进程,再通过用SetWindowLong替换窗口的WNDPROC,在自己的窗口函数中修改消息。
      

  2.   

    Hooks provide powerful capabilities for Windows-based applications. These applications can use hooks to: Process or modify all messages meant for all the dialog boxes, message boxes, scroll bars, or menus for an application (WH_MSGFILTER). 
    Process or modify all messages meant for all the dialog boxes, message boxes, scroll bars, or menus for the system (WH_SYSMSGFILTER). 
    Process or modify all messages (of any type) for the system whenever a GetMessage or a PeekMessage function is called (WH_GETMESSAGE). 
    Process or modify all messages (of any type) whenever a SendMessage function is called (WH_CALLWNDPROC). 
    Record or play back keyboard and mouse events (WH_JOURNALRECORD, WH_JOURNALPLAYBACK). 
    Process, modify, or remove keyboard events (WH_KEYBOARD). 
    Process, modify, or discard mouse events (WH_MOUSE). 
    Respond to certain system actions, making it possible to develop computer-based training (CBT) for applications (WH_CBT). 
    Prevent another filter from being called (WH_DEBUG). http://msdn.microsoft.com/en-us/library/ms997537.aspx
    难道MSDN忽悠我?
      

  3.   

    在你贴出的链接的中间部分,“Types of Hooks”下面:
    WH_CALLWNDPROC
    Windows calls this hook whenever the Windows SendMessage function is called. The filter functions receive a hook code from Windows indicating whether the message was sent from the current thread and receive a pointer to a structure containing the actual message.The CWPSTRUCT structure has the following form:Copytypedef struct tagCWPSTRUCT {
        LPARAM  lParam;
        WPARAM  wParam;
        DWORD   message;
        HWND    hwnd;
    } CWPSTRUCT, *PCWPSTRUCT, NEAR *NPCWPSTRUCT, FAR *LPCWPSTRUCT;Filters can process the message, but cannot modify the message (this was possible in 16-bit Windows). The message is sent to the Windows function for which it was intended. This hook is a significant drain on system performance, especially when it is installed as a systemwide hook, so use it only as a development or debugging tool.