获取COM服务器的进程ID
-
15-11-2019 - |
题
我正在通过直接发送到HWND的Windows消息的组合进行一些自动化,并呼叫自动应用程序公开的COM服务器。
如果运行多个实例,我需要能够确定COM服务器的进程ID,以便我可以使用COM呼叫作为我发送Windows消息的COM呼叫命中相同的实例。
我可以用运行的对象表枚举所有正在运行的COM服务器并获取所有运行的COM服务器并获取所有它们的怪人,但是COM对象本身揭露了我可以使用的方法来获取窗口句柄,线程ID,进程ID或任何内容那个。
是有没有办法弄清楚,基于绰号或绰号的实际绑定COM对象,COM服务器的进程ID是什么?
谢谢!
解决方案
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.
其他提示
I believe the kimgr CoGetServerPID function will give you the process-id of your COM server.
不隶属于 StackOverflow