获取COM服务器的进程ID [英] Get Process ID of COM Server

查看:178
本文介绍了获取COM服务器的进程ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过直接发送到HWND的Windows消息和对自动化应用程序公开的COM服务器的调用组合进行一些自动化。

I'm doing some automation via a combination of windows message sending directly to HWNDs and calls to a COM server exposed by the automated application.

如果有更多比一个实例运行,我需要能够确定COM服务器的进程ID,所以我可以命中相同的实例与COM调用作为我发送Windows消息的一个。

If there is more than one instance running, I need to be able to determine the process ID of the COM server so I can hit the same instance with the COM call as the one I'm sending windows messages to.

我可以枚举所有正在运行的COM服务器与运行的对象表,并获得所有他们的绰号,但COM对象本身暴露没有方法,我可以使用得到一个窗口句柄,线程ID,进程ID ,或任何这种类型。

I can enumerate all the running COM servers with the running object table and get back monikers for all of them, but the COM objects themselves expose no methods I can use to get a window handle, thread ID, process ID, or anything of that sort.

有什么方法来确定,基于绰号或实际的绑定COM对象的绰号,什么进程ID的COM服务器是?

Is there any way to figure out, based on a moniker or the actual binding COM object of the moniker, what the process ID of the COM server is?

谢谢!

推荐答案

编写代码)服务器和客户端,你可以添加一个方法到你的COM接口,将返回进程/线程ID或任何这种性质(例如服务器主机名(如果它是远程的)在服务器端。我第二@Hans - 除非你有访问服务器实现,你可能是运气不好的设计。

If you control (write code for) both the server and the client you can add a method to your COM interface that would return the process / thread ID or anything of this nature (e.g. server hostname if it is remote) on the server end. I second @Hans - unless you have access to the server implementation you may be out of luck by design.

这篇关于获取COM服务器的进程ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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