Paul
Paul

Reputation: 26680

A dual Windows Service / GUI applicaton with Delphi

Is a dual Windows Service / GUI applicaton possible with Delphi?

I mean, when its exeutable file is started normally, it appears as a normal GUI application that is used for something other than its Windows Service function. For example, a configurator for Windows Service. Or, for example, in GUI mode it could be a database client with TDBGrid etc and in Sevice mode it starts its own HTTP server and acts as a web application. Both are sharing the same database access code.

I looked into TServiceApplication.Run and didn't understand how can I distinguish between normal start and start as a service.

Of course, I could put some command line switch branching around this construct:

if GuiModeSwitch then begin
  Forms.Application.Initialize;
  Forms.Application.CreateForm(TConfigForm, ConfigForm);
  Forms.Application.Run;
end
else begin
  SvcMgr.Application.Initialize;
  SvcMgr.Application.CreateForm(TMyService, MyService);
  SvcMgr.Application.Run;
end;

But I would like that the GUI mode is started when no command line parameters are specified.

Upvotes: 0

Views: 349

Answers (1)

JavaDeveloper
JavaDeveloper

Reputation: 25

Maybe the SvCom component can help you in Delphi pascal window service setting up.

Step 6. Use service application as a regular one

Upvotes: 0

Related Questions