Jump to content


Photo

Convert a project from 'Desktop' to 'Service'


  • Please log in to reply
4 replies to this topic

#1 fabiorov

fabiorov

    Member

  • uniGUI Subscriber
  • PipPip
  • 20 posts

Posted 10 September 2017 - 11:40 PM

Hi Everybody

 

I have a project in 'desktop' mode, and I don't want to create a new one, copy/paste forms to convert it to ''service'.

 

Is there a simpler way to perform this conversion?

 

I am using 'uniGUI Personal Edition'

 


  • 0

#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3856 posts

Posted 11 September 2017 - 04:35 AM

Hi,

 

"If you want to convert a standard uniGUI app to service app, the best way is to create a new Service app and then moving all forms and modules from old app to the new app."

 

Best regards,


  • 1

#3 rgreat

rgreat

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 120 posts

Posted 12 September 2017 - 01:59 AM

You can edit your project dpr file using this template and have all 3 modes in one project simultaneously:

// Use one of 3 defines below to choose compile mode:

//{$DEFINE UNIGUI_VCL}      // Stand Alone Application.
//{$DEFINE UNIGUI_SERVICE}  // Windows Service Application.
//{$DEFINE UNIGUI_ISAPI}    // ISAPI Library.

{$IFDEF UNIGUI_SERVICE}
  {$EXTENSION exe}
  program
{$ENDIF}

{$IFDEF UNIGUI_VCL}
  {$EXTENSION exe}
  program
{$ENDIF}

{$IFDEF UNIGUI_ISAPI}
  {$EXTENSION dll}
  library
{$ENDIF}
  MyProgram;  // Your project name.

uses
{$IFDEF UNIGUI_SERVICE}
  SvcMgr,
{$ENDIF}
{$IFDEF UNIGUI_VCL}
  Forms,
{$ENDIF}
{$IFDEF UNIGUI_ISAPI}
  uniGUIISAPI,
{$ENDIF}
  ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule},
  MainModule in 'MainModule.pas' {UniMainModule: TUniGUIMainModule},
  ServiceModule in 'ServiceModule.pas' {MyServiceClass: TUniGUIService}, // Grab this one from a new project. 
  // Add your custom units here.  

{$R *.res}


{$IFDEF UNIGUI_ISAPI}
exports
  GetExtensionVersion,
  HttpExtensionProc,
  TerminateExtension;
{$ENDIF}

begin
{$IFDEF UNIGUI_SERVICE}
  if not Application.DelayInitialize or Application.Installing then
    Application.Initialize;
  Application.CreateForm(TMyServiceClass, MyServiceClass);  // Get from your service module.
  Application.Run;
{$ENDIF}

{$IFDEF UNIGUI_VCL}
  ReportMemoryLeaksOnShutdown:=True;  // Optional.
  Application.Initialize;
  TUniServerModule.Create(Application);
  Application.Run;
{$ENDIF}
end.


  • 3

#4 alesf76

alesf76

    Member

  • uniGUI Subscriber
  • PipPip
  • 17 posts

Posted 01 January 2018 - 09:22 PM

 

You can edit your project dpr file using this template and have all 3 modes in one project simultaneously:

// Use one of 3 defines below to choose compile mode:

//{$DEFINE UNIGUI_VCL}      // Stand Alone Application.
//{$DEFINE UNIGUI_SERVICE}  // Windows Service Application.
//{$DEFINE UNIGUI_ISAPI}    // ISAPI Library.

{$IFDEF UNIGUI_SERVICE}
  {$EXTENSION exe}
  program
{$ENDIF}

{$IFDEF UNIGUI_VCL}
  {$EXTENSION exe}
  program
{$ENDIF}

{$IFDEF UNIGUI_ISAPI}
  {$EXTENSION dll}
  library
{$ENDIF}
  MyProgram;  // Your project name.

uses
{$IFDEF UNIGUI_SERVICE}
  SvcMgr,
{$ENDIF}
{$IFDEF UNIGUI_VCL}
  Forms,
{$ENDIF}
{$IFDEF UNIGUI_ISAPI}
  uniGUIISAPI,
{$ENDIF}
  ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule},
  MainModule in 'MainModule.pas' {UniMainModule: TUniGUIMainModule},
  ServiceModule in 'ServiceModule.pas' {MyServiceClass: TUniGUIService}, // Grab this one from a new project. 
  // Add your custom units here.  

{$R *.res}


{$IFDEF UNIGUI_ISAPI}
exports
  GetExtensionVersion,
  HttpExtensionProc,
  TerminateExtension;
{$ENDIF}

begin
{$IFDEF UNIGUI_SERVICE}
  if not Application.DelayInitialize or Application.Installing then
    Application.Initialize;
  Application.CreateForm(TMyServiceClass, MyServiceClass);  // Get from your service module.
  Application.Run;
{$ENDIF}

{$IFDEF UNIGUI_VCL}
  ReportMemoryLeaksOnShutdown:=True;  // Optional.
  Application.Initialize;
  TUniServerModule.Create(Application);
  Application.Run;
{$ENDIF}
end.

 

It works perfectly! Thanks.


  • 0

#5 fabiorov

fabiorov

    Member

  • uniGUI Subscriber
  • PipPip
  • 20 posts

Posted 02 January 2018 - 06:38 PM

Thanks for the info.

 

Anyway, I fixed the problem by other mean ....

 

I use the software "AlwaysUp" (https://www.coretech...ducts/AlwaysUp/) to keep running a Java application, and I'm also using it for unigui App, so I can build the app as a normal application and run it as a service.

 

Best Regards.


  • 1




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users