Jump to content

Dual mode application console+service


alesf76

Recommended Posts

I use a command line parameter to say the application to run as a process or as a service.

I'm sure there is a better way, but it works for me.

The dpr looks like this...

 

 

program main;
uses
  SvcMgr,
  ServiceModule in 'ServiceModule.pas' {mainWebService: TUniGUIService},
  Forms,  Windows,  Classes,  SysUtils,
  ServerModule  in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule},
  Login         in 'Login.pas' {LoginForm: TUniLoginForm},
  MainModule    in 'MainModule.pas' {UniMainModule: TUniGUIMainModule},
  Main          in 'Main.pas' {MainForm: TUniForm};

{$R *.res}

begin

 

    if upperCase( paramStr(1)  ) <> '/APP' then
        with SvcMgr.Application do begin
            //started at system32...
            SetCurrentDir( extractFileDir(paramStr(0)) );
            if not DelayInitialize or Installing then
                Initialize;

            CreateForm(TmainVstWebService, mainVstWebService);
            Run;
        end
    else with Forms.Application do begin
        Initialize;
        TUniServerModule.Create(Forms.Application);
        Run;
    end;

end.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...