There is a scenario I'm interested in.
User runs COM based application in a separate window, I want my C# application to manipulate that application through COM calls. I've found COM interface I'm interested in and VisualStudio has successfully generated wrapper (MyApp.interop). So I can write something like new Interop.MyApplication()
but I do not want new Application I want to 开发者_如何学编程work with existing one.
I've found the solution, code looks like
var app = Marshal.GetActiveObject("MapInfo.Application")
((MyApp)app).OpenFile(...)
精彩评论