I've created a number of working programs with Borland Delphi 1, 2 and 5 (and still use Delphi at work) so am familiar with most of the basic conventions. However, I'm mystified when it comes to service apps. I've had a stab at a service that should simply write numbers to a text file using an fptimer, but I'm frustrated to find that I can't test it.
From
http://wiki.freepascal.org/Daemons_and_Services:
When the daemon is started the command line parameters are parsed. The following are predefined:
-i --install: register the daemon. This has no effect under unix.
-u --uninstall: unregister the daemon. This has no effect under unix.
-r --run: start the daemon. Windows does this normally itself.This implies that all I need to do after compiling my program is to type <programname> -i - in my case,
bdaemon - i. I compiled it successfully, opened the folder and could see
bdaemon.exe there. I right-clicked Windows Command Processor on my menu and selected "Run as administrator" and typed
bdaemon -i. No error: good.
I realise that this won't start the service, and that I need to do this manually, or by restarting Windows. However, when I go into
Computer | Manage | Services and Applications | Services, surely I should then see bdaemon (or Bdaemon) in the alphabetical list? It's not there and I have no idea why. Down at the first hurdle...
I can't find an example of how to use Lazdaemon with a step-by-step description of the requirements for Windows services. The Wiki is "bare bones" to say the least, and lumps Windows together with Unix. I'm completely unable to translate the following into what I need to do in my code.
TDaemonMapper
This component handles the service registration. Each instance needs one entry in the property DaemonDefs.My project does contain the following standard code, added automatically by Lazarus:
type
TDaemonMapper1 = class(TDaemonMapper)
private
{ private declarations }
public
{ public declarations }
end;
var
DaemonMapper1: TDaemonMapper1;
implementation
procedure RegisterMapper;
begin
RegisterDaemonMapper(TDaemonMapper1)
end;
{$R *.lfm}
initialization
RegisterMapper;
end.
I'm fairly sure I've missed a property but have no idea what to add, or where. I would be grateful if anyone is able to tell me what I've done wrong, or point me to an example of how to use LazDaemon with Windows.