Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
756 views
in Technique[技术] by (71.8m points)

winapi - Get Process ID of COM Server

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.

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.

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.

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?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...