如何重用一个(Delphi)OLE服务器与第二个客户端? [英] How to reuse a (Delphi) OLE server with a second client?

查看:227
本文介绍了如何重用一个(Delphi)OLE服务器与第二个客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个OLE自动化服务器(使用Delphi)。我通常手动启动OLE服务器,并将其用作正常的应用程序。我不时启动一个客户端,
自动连接到现有的OLE服务器。

I wrote an OLE automation server (using Delphi). I usually start the OLE server manually and use it as a normal application. From time to time I start a client, which automatically connect to the existing OLE Server.

当我终止客户端时,服务器不会终止最少当它在客户端之前手动启动时),但它不会接受任何其他OLE连接。

When I terminate the client, the server does not terminate (at least when it was started manually before the client) but it won't accept any other OLE connection. Starting another client will trigger a new server instead of reusing the first one.

如何重新使用与第二个客户端相同的服务器?

How can I reuse the same server with the second client?

(问题编辑重新格式化它在正确的版本,我在问如何防止服务器终止,这不是一个好的配方)

(Question edited to reformulate it correctly. In the original version I was asking how to prevent the server from terminating, which wasn't a good formulation)

推荐答案

在Delphi中的COM对象向导中有一个设置Instancing。允许的值为内部,多个实例,单个实例。

There is a setting "Instancing" in the COM Object Wizard in Delphi. Allowed values are "internal", "Multiple Instance", "Single Instance".

我想对多个客户端重复使用相同的COM服务器。这就是为什么我选择单实例,虽然我会有一个单一的实例我的服务器应用程序的所有客户端。但我错了。 单实例表示在我的服务器中只有一个COM连接的实例。我应该选择多实例允许多个COM连接(但一个接一个,而不是同时)在同一个服务器。

I wanted to reuse the same COM server with multiple clients. That is why I chose "single Instance" and though that I would have a single instance of my server application for all the clients. But I was wrong. "Single Instance" means that there will be only one instance of a COM connection in my server. I should have chosen "Multiple Instance" to allow multiple COM connection (but one after the other, not simultaneous) in the same server.

我认为Delphi中的COM对象向导并不是很清楚。代替多实例,单实例,最好是在这个关于OLE Server和VB的文章

I think that the words used in the COM Object Wizard in Delphi are not really clear. Instead of "multiple instance", "single instance", it would be better to have "multiuse" and "single use" like in this article about OLE Server and VB.

这篇关于如何重用一个(Delphi)OLE服务器与第二个客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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