Implementing a "TService" with RO

RO Gurus

I have recently discovered that implementing multiple instances of a service, which is based on TService, is not trivial. Yet, I have easily done just that with our RODA middle tier.

Question,
Can you please shed some light on how I can use the TROService to replace our TService application. Is it is simple as I imagine?

Regards,
Monte Carver

Note: This is how I accomplished this need within RO
In the dpr, I did:

var
  lAppPath : string;
  lVSName: string;
begin
  lAppPath := fxGetAppPath;
  with TIniFile.Create(lAppPath + 'MT.ini') do
  try
    lVSName  := ReadString(   'CONNECT', 'VirtualSvcName'  , 'CCOK_MTSvc_A');
  finally
    Free;
  end; //IniFile

  if ROStartService(lVSName, lVSName) then
  begin
     ROService.CreateForm(THDM, HDM);
     ROService.Run;
     Exit;
  end;
  Application.Initialize;
  Application.CreateForm(THDM, HDM);
  Application.CreateForm(TfrmMain, frmMain);
  Application.Run;
end;

Using: Delphi XE Seattle
RO 9.2.X

Hi Monte Carver

here a simple sample:

var
  sname: string;
  sdesc: string;
  I: Integer;
  descr: string;

begin
  sname := 'MyServer';
  sdesc := 'PCSoft Application Server';
  for I := 0 to ParamCount do
  begin
    if ( Pos( '/help', ParamStr( I ) ) > 0 ) or ( Pos( '/h', ParamStr( I ) ) > 0 ) or ( Pos( '-h', ParamStr( I ) ) > 0 ) then
    begin
      descr := 'I flag attivi per il servizio MyServer sono:' + #13#10#13#10 + #9 + '/install per installare MyServer come un servizio Windows' + #13#10#13#10 + #9 + '/uninstall per disinstallare MyServer dalla lista dei servizi Windows' +
        #13#10#13#10 + #9 + '/sname:NOME_DEL_SERVIZIO per specificare, in fase di installazione del' + #13#10 + #9 + ' servizio MyServer un nome' + #13#10#13#10 + 'Di seguito alcuni esempi di utilizzo:' + #13#10#13#10 + #9 +
        'MyServer /install per installare il servizio' + #13#10#13#10 + #9 + 'MyServer /uninstall per disinstallare il servizio' + #13#10#13#10 + #9 + 'MyServer /sname:MyServer /install per installare il servizio' + #13#10 + #9 +
        'con il nome specificato' + #13#10#13#10 + #9 + 'MyServer /sname:MyServer /uninstall per disinstallare il servizio' + #13#10 + #9 + 'a cui รจ stato specificato un nome';

      Application.MessageBox( PWideChar( descr ), 'MyServer help' );
      Exit;
    end;

    if Pos( '/sname:', ParamStr( I ) ) > 0 then
    begin
      sname := Trim( Copy( ParamStr( I ), Pos( ':', ParamStr( I ) ) + 1, Length( ParamStr( I ) ) ) );
      if sname = EmptyStr then
        sname := 'MyServer';
    end;
  end;

  if ROStartService( sname, sname, sdesc, stAuto, EmptyStr, stWin32, EmptyStr, EmptyStr, '---', Format( '/sname:%s', [ sname ] ) ) then
  begin
    ROService.CreateForm( TServerDataModule, ServerDataModule );
    ROService.Run;
    Exit;
  end;
Application.Initialize;
Application.Title := 'MyServer';
Application.CreateForm( TServerDataModule, ServerDataModule );
Application.CreateForm( TServerForm, ServerForm );
Application.Run;
end.

Run app with /help or /h or -h to show the Help.

Best Regards

Claudio