Delphi - multiple remote com objects

梦想与她 提交于 2020-01-06 01:58:49

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/7647289/delphi-multiple-remote-com-objects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!