如何拦截发送到窗口的消息? [英] How do I intercept messages being sent to a window?

查看:502
本文介绍了如何拦截发送到窗口的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要拦截在不同进程中发送到窗口的消息。什么是最好的方法做到这一点?当我使用WH_GETMESSAGE钩子,我不能看到消息,我不知道我是否可以跨进程子类。任何帮助将非常感激。

I want to intercept messages that are being sent to a window in a different process. What is the best way to do this? I can't see the messages when I use the WH_GETMESSAGE hook, and I'm not sure if I can subclass across processes? Any help would be much appreciated.

推荐答案

您需要注入自己的代码进入拥有您要拦截的窗口消息。幸运的是, SetWindowsHookEx() 使这相当容易,虽然你可能有一点麻烦,如果你只使用它进程挂钩到现在。

You need to inject your own code into the process that owns the windows you wish to intercept messages from. Fortunately, SetWindowsHookEx() makes this fairly easy, although you may have a bit of trouble at first if you've only used it for in-process hooking up to now.

我可以推荐两篇关于这个主题的精彩文章:

I can recommend two excellent articles on the subject:


  1. Joseph Newcomber的< a href =http://www.codeproject.com/KB/DLL/hooks.aspx =nofollow> Hooks和DLLs

  2. Robert Kuster的将代码注入另一个流程的三种方法

  1. Joseph Newcomber's Hooks and DLLs
  2. Robert Kuster's Three Ways to Inject Your Code into Another Process

这篇关于如何拦截发送到窗口的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆