Delphi - 多个远程com对象
我的 D5 应用程序位于由几个用户远程使用的服务器上,因此我需要使用以下函数创建 COM 对象来启动在启动时安装回该用户 PC 上的另一个应用程序 (LmPos):
CreateRemoteComObject(const MachineName: WideString; const ClassID: TGUID): IUnknown;
而不是创建本地 COM与以前一样的对象:
EposServer := CreateOLEObject('POS.Server');
但是,要连接到的 MachineName 和 ClassID 将取决于启动此应用程序的用户。我看到两个问题...
参数必须是常量,那么如何为它们分配变量呢?或者这是不可能的,因为它们是常数。
如果我需要用户输入,如何将字符串转换为 TGUID?它似乎只接受格式 := '{xxxx-xxxx-xxxx 等}'
任何帮助将不胜感激。我什至不确定目前是否可行,我正在尝试配置 DCOM 但没有成功。
My D5 application is on a server being used remotely by a couple of users, so I need use the following function to create a COM object to launch another application (LmPos) installed back on that users PC upon launch:
CreateRemoteComObject(const MachineName: WideString; const ClassID: TGUID): IUnknown;
rather than creating a local COM object as before:
EposServer := CreateOLEObject('POS.Server');
However, the MachineName and ClassID to connect to will depend on which users is launching this application. I see two problems with this...
The parameters must be constant, so how can I assign them variable? Or is this impossible as they're constants.
If I demand user input, how do I convert the String in to a TGUID? It only seems to accept the format := '{xxxx-xxxx-xxxx etc}'
Any help would be greatly appreciated. I'm not even sure if this is possible at present, I'm attempting to configure DCOM but not succeeding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK 服务器上的 DCOM 远程应用程序将始终以当前用户登录的方式运行,如您所述。
如果可以的话,摆脱 DCOM。这是一项已弃用的技术,Windows 7 和 2008 Server 不喜欢它。您需要在 PC 上强制使用 SMB 1 协议,即使这样,我们也遇到了很多问题。
我最近在一些 Delphi 5 应用程序池中遇到了类似的问题。我使用 http.sys 内核模式服务器 在 Windows 服务中运行(在服务器启动时启动,甚至在任何用户登录之前启动),并且 WinHTTP 用于客户端,它模仿初始 DCOM 类(因此在客户端仅更改了一个单位)。由于 HTTP 是无状态的,为了将事件从服务器推送到客户端,我在客户端类中添加了一个基于计时器的查询,以从服务器检索任何待处理的事件(500 毫秒的计时就足够且高效)。该解决方案与 Delphi 5 现有代码完美结合,最终客户非常喜欢其速度和稳定性。
AFAIK the DCOM remote application on server will always run with the current user logged, as you stated.
Get rid of DCOM if you can. It is a deprecated technology, and Windows Seven and 2008 Server do not like it. You'll need to force SMB 1 protocol on PCs, and even with that, we had a lot of problems.
I faced a similar issue recently with some Delphi 5 pool of applications. I converted the DCOM calls of existing Delphi 5 applications into a HTTP service, using http.sys kernel-mode server running in a Windows service (launched at server startup, even before any user is logged on), and WinHTTP for the client, which mimics the initial DCOM class (so on the client only one unit changed). Since HTTP is stateless, in order to push events from the server to the clients, I added a timer-based query in the client class, to retrieve any pending event from the server (a 500 ms timing is enough and efficient). This solution worked like a charm with Delphi 5 existing code, and the final customers just like the result in terms of speed and stability.