RobYost Posted May 26, 2017 Share Posted May 26, 2017 I have a project that is a stand alone exe. I would like to keep it that way for debugging, but I would like to set an $DEFINE to build it as a service. Is there something written up that would help me do this? Quote Link to comment Share on other sites More sharing options...
RobYost Posted May 27, 2017 Author Share Posted May 27, 2017 I think I figured it out. Add to the Uses {$IFDEF RELEASE} SvcMgr, ServiceModule in 'Service\ServiceModule.pas' {SimpleLandlordService: TUniGUIService}, {$ELSE} Forms, {$ENDIF } Below the begin: {$IFDEF RELEASE} if not Application.DelayInitialize or Application.Installing then Application.Initialize; Application.CreateForm(TSimpleLandlordService, SimpleLandlordService); Application.Run; {$ELSE} //WHAT EVER YOU CURRENTY HAVE BELOW Application.Initialize; Tsm.Create(Application); Application.Run; {$ENDIF} I still need to do more testing. But it looks like my logging to CodeSite doesn't work when I run it as a service. -UPDATE: it works to my logfile, but not to the live viewer. But that is a codesite limitation Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted May 27, 2017 Share Posted May 27, 2017 I make it similar to you. My only problem is when adding a new form or frame in debug mode Delphi deletes sometimes the "ServiceModule in 'Service\ServiceModule.pas'". Do you have same problem? Quote Link to comment Share on other sites More sharing options...
RobYost Posted May 27, 2017 Author Share Posted May 27, 2017 Yes this has happened to me. I have had to re-add the service module to the project. Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted May 27, 2017 Share Posted May 27, 2017 Thanks for the information. Seems to be a delphi problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.