Switch between standalone EXE and Windows services

I wrote an application that sends journals by mail in a timer. This application has a minimalistic user interface, and after the configuration file is there, it can start without the need for user interaction.

This is currently a VCL Forms application, but in some cases it would be nice to have a service (thus, when starting on the server, there is no need to open a user session just to start the application).

What do you offer in order to have both worlds? In some simple scenario (smal organization, only 3 pieces. And the absence of an IT manager), non-service is good because it is easier to understand and use, but in a larger organization, lack of service is a problem.

Is simultaneous service and non-service possible? How to achieve this? I don’t want the deployment to be more complicated, which I mean is some command line switch: when run with command line parasites, this can be a service, if not a regular application ... How to do this?).

+5
source share
3 answers

OK ... the best way is to develop a service and non service application in the same project. As described here: A standalone Delphi application that can also be installed as a Windows service . Thus, you can use the same application as a service or as a standalone application.

, : :

  • Verifiy, .
  • , , .
+5

, uf , , . , ..

.

+1

, . , .

  unit fTestHarness;

  interface

  uses
     uMyServiceModule,
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;

  type
    TfrmCentralTest = class(TForm)
      Label1: TLabel;
      Label2: TLabel;
      procedure FormCreate(Sender: TObject);
      procedure FormClose(Sender: TObject; var Action: TCloseAction);
    private
      { Private declarations }
    public
      { Public declarations }
    end;

  var
    frmTest: TfrmTest;

  implementation

  {$R *.dfm}

  procedure TfrmCentralTest.FormCreate(Sender: TObject);
  var
     bStarted : boolean;
  begin
     bStarted := False;
     MyService := TMyService.Create(self);
     MyService.ServiceStart(nil, bStarted);
  end;

  procedure TfrmCentralTest.FormClose(Sender: TObject; var Action: TCloseAction);
  var
     bStopped : boolean;
  begin
     MyService.ServiceStop(nil, bStopped);
  end;

  end.
0

All Articles