如何使用Marshal.getActiveObject()获取具有两个打开的正在运行的进程的2个实例 [英] How to use Marshal.getActiveObject() to get 2 instance of of a running process that has two processes open

查看:868
本文介绍了如何使用Marshal.getActiveObject()获取具有两个打开的正在运行的进程的2个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前我的代码使用

SurferApp = Marshal.GetActiveObject("Surfer.Application") as Surfer.Application

获取名为surfer的软件的运行实例,为简单起见,我们可以将Surfer替换为Word,每个人知道。
现在让我们说我有2个MS Word应用程序正在运行,我想使用 Marshal.GetActiveObject()来获取它们,我如何才能获得两个正在运行的实例并将每个对象与一个单独的对象关联?

to get the running instance of a software called surfer, for the sake of simplicity we can replace Surfer to Word that everyone knows about. Now let's say I have 2 MS word application running and I want to get both of them using Marshal.GetActiveObject(), how can I get both the running instances and associate each with a separate object?

推荐答案

Marshal.GetActiveObject返回它在ROT(运行对象表)上找到的第一个实例。如果您有多个使用相同名称/ ID运行的实例,则必须直接从ROT获得它。

Marshal.GetActiveObject returns the first instance it finds on ROT (running object table). If you have more than one instance running with the same name/id, you have to get it directly from ROT.

一些链接可以开始:

  • http://dotnet-snippets.de/dns/laufende-com-objekte-abfragen-SID526.aspx (German only)
  • http://www.codeproject.com/Articles/17490/Running-Object-Table-Provider-in-NET-consumer-in-M
  • http://www.codeproject.com/Articles/7984/Automating-a-specific-instance-of-Visual-Studio-NE

这篇关于如何使用Marshal.getActiveObject()获取具有两个打开的正在运行的进程的2个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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