Delphi out-of-process COM server without forms
I'd like to build an out-of-process COM server with Delphi that does not need any visual forms. The main purpose of that server is to provide some "out-of-process" p开发者_运维问答rocessing for other Windows Services. Is it possible to place COM objects into simple console application? I expect it will (at least) need some kind of message-handling loop inside. Can I place it inside of Windows Service instead?
You could do message handling yourself, but the Component Services tool in the Administrative Tools that are available in Windows, since Windows 2000 if I remember correctly, provides a way to select an ActiveX dll and have it run from a dllhost.exe process, optionally as an NT-service.
If you really want to you could start a plain exe project and add TAutoObject's to it, even to an NT-service project, but there's a little extra work to be done to get multi-instancing, security and concurrency right.
You can check SvCom for an explanation on what's different in running a DCOM server as a service, and for a library implementing it fully, supporting latest Delphi releases also.
精彩评论