一个独立的Delphi应用程序,也可以安装为Windows服务

编程入门 行业动态 更新时间:2024-10-28 14:33:24
本文介绍了一个独立的Delphi应用程序,也可以安装为Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在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服务

本文发布于:2023-11-06 22:05:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564795.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   独立   Delphi   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!