开发者

Call method in existing Com Application from my .NET application

开发者 https://www.devze.com 2023-01-19 01:02 出处:网络
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

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(...)
0

精彩评论

暂无评论...
验证码 换一张
取 消