How to get text from unmanaged application to a c# application?
I have a 3rd party application, which creates several windows of which each has a textbox with text I want. I then want to use that information within my application, so I just need to obtain that information (possible trigger some commands back to it later on by pressing buttons)
The 3rd party application is un-managed C++. My application is C# (.NET 4.0).
I have开发者_开发百科 seen that you can do 'hooks' into other application but I'll be honest I am completely lost of which route to take and how to go about it.
Some advice would be great.
I wonder if all this talk of managed code and unmanaged code and Interop isn't a red herring. Are you able to interface with this other app at all or are you just going to have to use FindWindow to find that other app and then enumerate it's child windows till you find the text boxes you're after, then just call GetWindowText ?
You will need to use COM interop. More here
http://msdn.microsoft.com/en-us/library/aa645736%28v=vs.71%29.aspx
http://www.liensberger.it/web/blog/?p=323
The easiest interop with an unmanaged C++ is via C++/CLI. If there's already a simple C wrapper then P/Invoke will be sufficient.
精彩评论