进程外COM服务器 [英] out-of-proc COM Server

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

问题描述

Hello



我使用一个基于C ++的第三方应用程序,通过COM IDispatch公开功能

服务器。从本质上讲,它是一个专有的数据库阅读器。这是一个写得很好的商业软件。允许这个C ++应用程序运行多个实例,我想知道是否
我可以控制哪个执行实例将用作COM服务器。



目前,我每天早上手动配置机器的方式如下



1)我开始C ++应用程序的第一个实例并正确地将它连接到数据库A.

2)我启动我的C#app作为此COM的客户端并将其绑定到仅运行的实例。

C#必须始终只与数据库A连接到COM服务器。

3)我启动C ++应用程序的第二个实例并将其连接到数据库B.



当C#app必须关闭时出现问题并重新启动。我还必须关闭第二个实例,否则我无法确定哪个进程将作为COM服务器响应。



在C#中,我可以非常轻松地检测正在运行的进程视频系统.Diagnostics.Process所以我可以知道我是否有多个实例。 COM Server确实公开了解已打开数据库名称的功能,但如何将其链接回执行进程?

Hello

I use one 3rd party C++ based application that exposes functionality thru a COM IDispatch
Server. Essentially, it is a proprietary database reader. It is a very well written commercial software. This C++ application is allowed to run multiple instances, I am wondering whether
or not I can control which executing instance will be used as the COM Server.

Currently, the way I manually configure the machine every morning is as follows

1) I start first instance of the C++ app and correctly connect it to database A.
2) I start my C# app that are clients to this COM and bind it to only running instance.
C# must always connect to COM server with database A only.
3) I start second instance of the C++ app and connect it to database B.

Problem occurs when C# app has to be closed and restarted. I also have to close off the second instance otherwise I cannot determine which process will respond as COM server.

In C#, I can very easily detect the running Processes vide System.Diagnostics.Process so I can know whether or not I have multiple instances. COM Server does expose functionality to know name of opened database but how do I link it back to the executing process?

推荐答案





听起来像是一个缺失的功能。也许您应该联系该公司并提出功能请求。 :)



如果COM服务器是本地的,那么你可以调用 NtQuerySystemInformation [ ^ ],带有SystemHandleInformation信息类,用于枚举所有打开的文件句柄并将其与进程ID匹配。这可能有效,也可能无效;这取决于保持持久打开文件句柄的过程。



另一个想法......是创建一个通过创建过程 [ ^ ]并让包装器进程导出用于获取进程ID的接口。



如果它是一台远程机器......通过RPC进行外部处理,那么很遗憾你运气不好。



祝福,

-David Delaune
Hi,

Sounds like a missing feature. Perhaps you should contact the company and make a feature request. :)

If the COM Server is local then you could probably call NtQuerySystemInformation[^] with the SystemHandleInformation information class for enumerating all open file handles and matching it with a process ID. This may or may not work; it depends on the process keeping a persistent open file handle.

Another idea... would be to create a wrapper process that launches the COM server via CreateProcess [^] and have the wrapper process export an interface for obtaining the process id.

If its a remote machine... out-of-proc via RPC then unfortunately you are out of luck.

Best Wishes,
-David Delaune


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

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