在Delphi中,您可以创建一个独立的Windows VCL Forms应用程序。您也可以创建一个Windows服务应用程序。
In Delphi you can create a standalone Windows VCL Forms application. You can also create a Windows service application.
可以将两个应用程序组合在一个可以作为独立应用程序运行的单个应用程序中,也可以作为Windows服务?
Is it possible to combine the two in a single application that can run as a standalone application and can also be installed as a Windows service?
推荐答案完全可能。诀窍是编辑.dpr以在要作为服务运行时作为应用程序和服务表单运行时创建主窗体。像这样:
Totally possible. The trick is to edit the .dpr to create main form when you want to run as an application and the service form when you want to run as a service. Like this:
if SvComFindCommand('config') then begin //When run with the /config switch, display the configuration dialog. Forms.Application.Initialize; Forms.Application.CreateForm(TfrmConfig, frmConfig); Forms.Application.Run; end else begin SvCom_NTService.Application.Initialize; SvCom_NTService.Application.CreateForm(TscmServiceSvc, scmServiceSvc); SvCom_NTService.Application.Run; end;上面的代码使用SvCom运行服务,但使用标准TService可以实现完全相同的效果
The code above uses SvCom to run the service but exactly the same effect could be achieved using the standard TService.
多年前,我为Delphi杂志撰写了一篇关于该文章的文章。您可以在这里阅读:许多应用程序的面孔。
I wrote an article about that for The Delphi Magazine many years ago. You can read it here: Many Faces Of An Application.
更多推荐
一个独立的Delphi应用程序,也可以安装为Windows服务
发布评论