Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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??
Posted
Comments
syed shanu 11-Jan-15 19:34pm    
Check my article might be helpful to you.
http://www.codeproject.com/Articles/792540/External-Program-Text-Read-using-VB-NET
ezio2000 12-Jan-15 7:56am    
Ty shanu, but I can't use your method (i.e. SendMessage + CB_GETLBTEXT) because the items in the ComboBox list are sorted, while I need them in input order, so i MUST get messages BEFORE them are sorted in the list.

1 solution

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
 
Share this answer
 
v2
Comments
ezio2000 12-Jan-15 8:01am    
Ty for the answer... however you answer with theory to a pratical question.

Well I know that I need a C++ dll, but since I don't know C++, for this reason I asked a VB.NET EasyHook example that could solve my purpose: if really to get messages with EasyHook i so simple... I think are few lines of code...
Sergey Alexandrovich Kryukov 12-Jan-15 14:16pm    
There are no too much examples (try to find some yourself), because not so many developers do this work.
If you don't know C++ or C++/CLI, you can use something you know, such as Free Pascal for Windows.
But you don't really need samples. Programming is mostly learned by writing code using the documentation, not reading code sample. As most of the developers, you can read the documentation and do it all from scratch. If not, you should better get to an easier task.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900