如何将消息发送到外部控件? [英] How do I can get messages sent to a external control?

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

问题描述

我的目标是拦截(通过VB.NET)发送到外部ComboBox控件(C ++程序)的所有CB_FINDSTRINGEXACT消息,我知道Handle,就像Spy ++那样(见下图链接):



查找间谍++消息



可能是EasyHook或其他一些Hook引擎......但是网上的文档确实很差(VB.NET中没什么)。 我问自己为什么5年或更长时间没有人发布更新关于挂钩的文章:可能是七点64位中的Hook并不像EasyHook那么轻松?

解决方案

所需的内容称为 全局 Windows Hook 。请参阅:

http ://msdn.microsoft.com/en-us/library/windows/desktop/ms632589%28v=vs.85%29.aspx [ ^ ],

< a href =http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx> http://msdn.microsoft.com/en-us /library/windows/desktop/ms644990%28v=vs.85%29.aspx [ ^ ]。



这里的关键是 global (请参阅上面引用的第一个MSDN库的 global 的解释)。它使问题变得更加困难:您将无法在VB.NET应用程序中使用P / Invoke和调用钩子方法。根据Microsoft文档,您需要在本机DLL中安装挂钩。如果您使用的是C ++,则适合编写此类DLL。然后你的应用程序可以使用这个DLL来完成剩下的工作。



混合模式中进行它是非常有益的( managed + unmamaged)C ++ / CLI项目,您可以将托管的.NET代码(ref托管类型)与非托管类型自由混合:

http://en.wikipedia.org/wiki/C%2B%2B/CLI [ ^ ],

http://www.ecma-international.org/publications/standards/Ecma-372.htm [ ^ ],

http://www.gotw.ca/publications/C++CLIRationale.pdf [ ^ ],

< a href =http://msdn.microsoft.com/en-us/library/xey702bw.aspx> http://msdn.microsoft.com/en-us/library/xey702bw.aspx [< a href =http://msdn.microsoft.com/en-us/library/xey702bw.aspxtarget =_ blanktitle =New Window> ^ ]。



请注意,基于钩子的应用程序在开发难度方面远高于平均水平,尤其是调试。



- SA

My goal is to intercept (by VB.NET) all CB_FINDSTRINGEXACT messages sent to an external ComboBox control (C++ program) of which I know the Handle, like Spy++ does (se the linked below image):

Spy++ messages looking for

May be by EasyHook or some other Hook engine... but online there is really poor documentation (and nothing in VB.NET). I ask myself why are 5 or more years that no one posts updated Articles about hooking: may be to Hook in Seven 64 bit is not so "Easy" as EasyHook tells??

解决方案

What it takes is called Global Windows Hook. Please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632589%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx[^].

The key here is global (please see the explanation of global starting from the first MSDN library referenced above). It makes the problem more difficult: you won't be able to just use P/Invoke and call hook methods in your VB.NET application. According to Microsoft documentation, you will need to install the hooks in the native DLL. If you are using C++, it will be suitable for writing such DLL. And then your application can use this DLL to do the rest.

It would be very beneficial to do it in a mixed-mode (managed + unmamaged) C++/CLI project where you can freely mix managed .NET code ("ref" managed types) with the unmanaged:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[^],
http://www.gotw.ca/publications/C++CLIRationale.pdf[^],
http://msdn.microsoft.com/en-us/library/xey702bw.aspx[^].

Note that the applications based on hook are well above average in terms of difficulty of development, especially debugging.

—SA


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

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