Jump to content

Convert a project from 'Desktop' to 'Service'


fabiorov

Recommended Posts

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.

  • Like 2
  • Thanks 1
  • Upvote 4
Link to comment
Share on other sites

  • 3 months later...

 

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.

Link to comment
Share on other sites

  • 3 years later...
On 9/12/2017 at 8:59 AM, rgreat said:

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.

Thanks

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...