[Lazarus] Where to define conditionals for FPC
Bo Berglund
bo.berglund at gmail.com
Thu May 14 10:21:22 CEST 2020
On Tue, 12 May 2020 13:49:08 +0200, Marc Weustink via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
While going through your post I got into this section:
>> 3) Compiling same code with Delphi and FPC?
>> Do you convert your projects (manually) to make it possible to use
>> both Delphi and Lazarus as the IDE for further work on the same
>> sources?
>> If so do you have any hints as to what to look out for?
>
>Yes, it is a manual conversion. But in our case not that hard. Most of
>the converted projects are windows (network) services.
>The difference between a delphi service and a fpc daemon is covered in a
>BaseServer class / unit. So for services derived from it there is no
>different code.
Since I am dealing with a Windows Service too I wonder how you do it
to get a daemon application in Lazarus?
I have installed the package lazdaemon 0.9.9 on advice elsewhere.
It is said to be implementing services, but I don't know if it is
involved in the Delphi conversion...
Coide snippets:
My service application is created in the dpr file:
if not Application.DelayInitialize or Application.Installing then
Application.Initialize;
Application.CreateForm(TSSRemoteServer, SSRemoteServer);
Application.Run;
And in the main source file:
type
TSSRemoteServer = class(TService) // <== Using TService
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure ServiceStop(Sender: TService; var Stopped: Boolean);
procedure ServiceShutdown(Sender: TService);
procedure ServiceDestroy(Sender: TObject);
procedure ServiceCreate(Sender: TObject);
private
{$IFNDEF FPC} //Delphi
sckServer: TServerSocket;
{$ELSE} //FPC
sckServer: TLTcp; //lNet socket
{$ENDIF}
.... normal field and method declarations follow ...
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
SSRemoteServer.Controller(CtrlCode);
end;
....
var
SSRemoteServer: TSSRemoteServer;
--
Bo Berglund
Developer in Sweden
More information about the lazarus
mailing list