Daemon (service) application class

The daemonapp unit implements a TApplication class which encapsulates a daemon or service application. It handles installation where this is necessary, and does instantiation of the various daemons where necessary.

The unit consists of 3 separate classes which cooperate tightly:

TDaemon
This is a class that implements the daemon's functionality. One or more descendents of this class can be implemented and instantiated in a single daemon application. For more information, see .
TDaemonApplication
This is the actual daemon application class. A global instance of this class is instantiated. It handles the command-line arguments, and instantiates the various daemons. For more information, see .
TDaemonDef
This class defines the daemon in the operation system. The TDaemonApplication class has a collection of TDaemonDef instances, which it uses to start the various daemons. For more information, see .

As can be seen, a single application can implement one ore more daemons (services). Each daemon will be run in a separate thread which is controlled by the application class.

The classes take care of logging through the TEventLog class.

Many options are needed only to make the application behave as a windows service application on windows. These options are ignored in unix-like environment. The documentation will mention this.

Daemon application architecture

[Still needs to be completed]

Definition of TCustomApplication Components and collections. Exception support and formatting routines Event logging class. Constant strings for messages Base daemon application class

TCustomDaemon implements all the basic calls that are needed for a daemon to function. Descendents of TCustomDaemon can override these calls to implement the daemon-specific behaviour.

TCustomDaemon is an abstract class, it should never be instantiated. Either a descendent of it must be created and instantiated, or a descendent of can be designed to implement the behaviour of the daemon.

Internal daemon controller class TDaemonController is a class that is used by the class to control the daemon during runtime. The TDaemonApplication class instantiates an instance of TDaemonController for each daemon in the application and communicates with the daemon through the TDaemonController instance. It should rarely be necessary to access or use this class. Daemon event handler prototype TDaemonEvent is used in event handling. The Sender is the instance that has initiated the event. Daemon instance Daemon acknowledgement event handler TDaemonOKEvent is used in event handling, when a boolean result must be obtained, for instance, to see if an operation was performed succesfully. Daemon instance Operation was successful Daemon options Enumerated that enumerates the various daemon operation options. The daemon can be stopped. The daemon can be paused. The daemon interacts with the desktop. Set of options. TDaemonOption enumerates the various options a daemon can have. Daemon application run mode TDaemonRunMode indicates in what mode the daemon application (as a whole) is currently running. RunMode Unknown mode Daemon install mode (windows only) Daemon uninstall mode (windows only) Daemon is running normally Daemon definition TDaemonDef contains the definition of a daemon in the application: The name of the daemon, which descendent should be started to run the daemon, a description, and various other options should be set in this class. The global TDaemonApplication instance maintains a collection of TDaemonDef instances and will use these definitions to install or start the various daemons. Additional command-line arguments when running daemon. RunArguments specifies any additional command-line arguments that should be specified when running the daemon: these arguments will be passed to the service manager when registering the service on windows. Current daemon status TCurrentStatus indicates the current state of the daemon. It changes from one state to the next during the time the instance is active. The daemon application changes the state of the daemon, depending on signals it gets from the operating system, by calling the appropriate methods. The daemon is stopped, i.e. inactive. The daemon is starting, but not yet fully running. The daemon is stopping, but not yet fully stopped. The daemon is running (it is operational). The daemon is continuing, but not yet running The daemon is about to be paused. The daemon is paused: running but not active. Log a message to the system log

LogMessage can be used to send a message Msg to the system log. A TEventLog instance is used to actually send messages to the system log.

The message is sent with an 'error' flag (using TEventLog.Error).

None. ReportStatus
Message to send to the system log Report the current status to the operating system

ReportStatus can be used to report the current status to the operating system. The start and stop or pause and continue operations can be slow to start up. This call can (and should) be used to report the current status to the operating system during such lengthy operations, or else it may conclude that the daemon has died.

This call is mostly important on windows operating systems, to notify the service manager that the operation is still in progress.

The implementation of ReportStatus simply calls ReportStatus in the controller.

None. LogMessage
The definition used to instantiate this daemon instance Definition is the definition that was used to start the daemon instance. It can be used to retrieve additional information about the intended behaviour of the daemon. Thread in which daemon is running DaemonThread is the thread in which the daemon instance is running. Each daemon instance in the application runs in it's own thread, none of which are the main thread of the application. The application main thread is used to handle control messages coming from the operating system. Controller TDaemonController instance controlling this daemon instance Controller points to the TDaemonController instance that was created by the application instance to control this daemon. DaemonThread Current status of the daemon

Status indicates the current status of the daemon. It is set by the various operations that the controller operates on the daemon, and should not be set manually.

Status is the value which ReportStatus will send to the operating system.

ReportStatus
TEventLog instance used to send messages to the system log Logger is the TEventLog instance used to send messages to the system log. It is used by the LogMessage call, but is acessible through the Logger property in case more configurable logging is needed than offered by LogMessage. LogMessage TEventLog Class type for TCustomDaemon The class type is needed in the definition. Prototype for event to handle a custom control code In case the system sends a non-standard control code to the daemon, an event handler is executed with this prototype. Daemon instance for which the control event was meant Control code being sent to the daemon Was the control code handled ? Daemon class for visual development

TDaemon is a descendent which is meant for development in a visual environment: it contains event handlers for all major operations. Whenever a TCustomDaemon method is executed, it's execution is shunted to the event handler, which can be filled with code in the IDE.

All the events of the daemon are executed in the thread in which the daemon's controller is running (as given by DaemonThread), which is not the main program thread.

Daemon start event

OnStart is the event called when the daemon must be started. This event handler should return as quickly as possible. If it must perform lengthy operations, it is best to report the status to the operating system at regular intervals using the ReportStatus method.

If the start of the daemon should do some continuous action, then this action should be performed in a new thread: this thread should then be created and started in the OnExecute event handler, so the event handler can return at once.

ReportStatus
Daemon stop event

OnStart is the event called when the daemon must be stopped. This event handler should return as quickly as possible. If it must perform lengthy operations, it is best to report the status to the operating system at regular intervals using the ReportStatus method.

If a thread was started in the OnExecute event, this is the place where the thread should be stopped.

ReportStatus
Daemon pause event

OnPause is the event called when the daemon must be stopped. This event handler should return as quickly as possible. If it must perform lengthy operations, it is best to report the status to the operating system at regular intervals using the ReportStatus method.

If a thread was started in the OnExecute event, this is the place where the thread's execution should be suspended.

ReportStatus
Daemon continue

OnPause is the event called when the daemon must be stopped. This event handler should return as quickly as possible. If it must perform lengthy operations, it is best to report the status to the operating system at regular intervals using the ReportStatus method.

If a thread was started in the OnExecute event and it was suspended in a OnPause event, this is the place where the thread's executed should be resumed.

ReportStatus
Daemon shutdown

OnShutDown is the event called when the daemon must be shut down. When the system is being shut down and the daemon does not respond to stop signals, then a shutdown message is sent to the daemon. This event can be used to respond to such a message. The daemon process will simply be stopped after this event.

If a thread was started in the OnExecute, this is the place where the thread's executed should be stopped or the thread freed from memory.

ReportStatus
Daemon execute event

OnExecute is executed once after the daemon was started. If assigned, it should perform whatever operation the daemon is designed.

If the daemon's action is event based, then no OnExecute handler is needed, and the events will control the daemon's execution: the daemon thread will then go in a loop, passing control messages to the daemon.

If an OnExecute event handler is present, the checking for control messages must be done by the implementation of the OnExecute handler.

Called before the daemon will be installed BeforeInstall is called before the daemon is installed. It can be done to specify extra dependencies, or change the daemon description etc. AfterInstall BeforeUnInstall AfterUnInstall Called after the daemon was installed AfterInstall is called after the daemon was succesfully installed. BeforeInstall BeforeUnInstall AfterUnInstall Called before the daemon is uninstalled BeforeUnInstall is called before the daemon is uninstalled. BeforeInstall AfterInstall AfterUnInstall Called after the daemon is uninstalled AfterUnInstall is called after the daemon is succesfully uninstalled. BeforeInstall AfterInstall BeforeUnInstall Called when a control code is received for the daemon OnControlCode is called when the daemon receives a control code. If the daemon has not handled the control code, it should set the Handled parameter to False. By default it is set to True. Architecture Create a new instance of the TDaemonController class Create creates a new instance of the TDaemonController class. It should never be necessary to create a new instance manually, because the controllers are created by the global instance, and AOwner will be set to the global instance. Destroy Owner of the controller. Free a TDaemonController instance. Destroy deallocates some resources allocated when the instance was created. Create Start the service StartService starts the service controlled by this instance. None. Daemon main entry point

Main is the service's main entry point, called when the system wants to start the service. The global application will call this function whenever required, with the appropriate arguments.

The standard implementation starts the daemon thread, and waits for it to stop. All other daemon action - such as responding to control code events - is handled by the thread.

If the daemon thread cannot be created, an exception is raised.
Command-line arguments passed by the OS. The first is normally the service name Arguments for the service. Controller

Controller is responsible for sending the control code to the daemon thread so it can be processed.

This routine is currently only used on windows, as there is no service manager on linux. Later on this may be changed to respond to signals on linux as well.

Control code sent by the system Event type sent by the system Additional event data sent by the system Report the status to the operating system. ReportStatus reports the status of the daemon to the operating system. On windows, this sends the current service status to the service manager. On other operating systems, this sends a message to the system log. If an error occurs, an error message is sent to the system log. True if the status was reported succesfully Daemon instance this controller controls. Daemon is the daemon instance that is controller by this instance of the TDaemonController class. Parameters passed to the daemon Params contains the parameters passed to the daemon application by the operating system, comparable to the application's command-line parameters. The property is set by the Main method. Last reported status LastStatus is the last status reported to the operating system. ReportStatus Send checkpoint signal to the operating system CheckPoint can be used to send a checkpoint signal during lengthy operations, to signal that a lengthy operation is in progress. This should be used mainly on windows, to signal the service manager that the service is alive. ReportStatus Class type of TDaemon Type of service (Windows only) The type of service. This type is used on windows only, to signal the operating system what kind of service is being installed or run. Regular win32 service Device driver File system driver Severity of a startup error (Windows only) TErrorSeverity determines what action windows takes when the daemon fails to start. It is used on windows only, and is ignored on other platforms. Ignore startup errors Error is logged, but startup continues Error is logged, and startup is continued if last known good configuration is active, or system is restarted using last known good configuration Error is logged, and startup is stopped if last known good configuration is active, or system is restarted using last known good configuration When should the daemon be started (windows only) TStartType can be used to define when the service must be started on windows. This type is not used on other platforms. During system boot During load of device drivers Started automatically by service manager during system startup Started manually by the user or other processes. Service is not started, it is disabled Container to define depenencies on other services. TDependency is a collection item used to specify dependencies on other daemons (services) in windows. It is used only on windows and when installing the daemon: changing the dependencies of a running daemon has no effect. Assign TDependency instance to another Assign is overridden by TDependency to copy all properties from one instance to another. Source instance to copy properties from Name of the service Name is the name of a service or service group that the current daemon depends on. Name refers to a service group IsGroup can be set to True to indicate that Name refers to the name of a service group. Dependencies collection for a daemon TDependencies is just a descendent of TCollection which contains a series of dependencies on other services. It overrides the default property of TCollection to return instances. Create a new instance of a TDependencies collection. Create Create a new instance of a TDependencies collection. Owner of the collection - normally a TDaemonDef instance. Default property override Items overrides the default property of TCollection so the items are of type . Zero based index of the dependency Windows Daemon bindings (windows only) TWinBindings contains windows-specific properties for the daemon definition (in ). If the daemon should not run on Windows, then the properties can be ignored. Create a new TWinBindings instance Create initializes various properties such as the dependencies. Remove a TWinBindings instance from memory Destroy cleans up the TWinBindings instance. Copies all properties Assign is overridden by TWinBindings so all properties are copied from Source to the TWinBindings instance. TWinBindings instance to copy properties from Service specific error code ErrCode contains a service specific error code that is reported with to the windows service manager. If it is zero, then the contents of Win32ErrCode are reported. If it is nonzero, then the windows-errorcode is set to ERROR_SERVICE_SPECIFIC_ERROR. General windows error code Win32ErrCode is a general windows service error code that can be reported with to the windows service manager. It is sent if ErrCode is zero. ErrCode Service dependencies

Dependencies contains the list of other services (or service groups) that this service depends on. Windows will first attempt to start these services prior to starting this service. If they cannot be started, then the service will not be started either.

This property is only used during installation of the service.

Service group name

GroupName specifies the name of a service group that the service belongs to. If it is empty, then the service does not belong to any group.

This property is only used during installation of the service.

Password for service startup

Password contains the service password: if the service is started with credentials other than one of the system users, then the password for the user must be entered here.

This property is only used during installation of the service.

UserName
Username to run service as

Username specifies the name of a user whose credentials should be used to run the service. If it is left empty, the service is run as the system user. The password can be set in the Password property.

This property is only used during installation of the service.

Password
Service startup type.

StartType specifies when the service should be started during system startup.

This property is only used during installation of the service.

Timeout wait hint

WaitHint specifies the estimated time for a start/stop/pause or continue operation (in milliseconds). Reportstatus should be called prior to this time to report the next status.

Location in the service group

IDTag contains the location of the service in the service group after installation of the service. It should not be set, it is reported by the service manager.

This property is only used during installation of the service.

Type of service

ServiceType specifies what kind of service is being installed.

This property is only used during installation of the service.

Error severity in case of startup failure

ErrorSeverity can be used at installation time to tell the windows service manager how to behave when the service fails to start during system startup.

This property is only used during installation of the service.

Create a new TDaemonDef instance Create initializes a new TDaemonDef instance. It should not be necessary to instantiate a definition manually, it is handled by the collection. Collection the item belongs in. Free a TDaemonDef from memory Destroy removes the TDaemonDef from memory. TDaemon class to use for this daemon DaemonClass is the TDaemon class that is used when this service is requested. It is looked up in the application's global daemon mapper by it's name in DaemonClassName. DaemonClassName Instance of the daemon class Instance points to the instance that is used when the service is in operation at runtime. Name of the TDaemon class to use for this daemon DaemonClassName is the name of the TDaemon class that will be used whenever the service is needed. The name is used to look up the class pointer registered in the daemon mapper, when creates an instance of the daemon. Name of the daemon (service) Name is the internal name of the daemon as it is known to the operating system. Displayed name of the daemon (service) DisplayName is the displayed name of the daemon as it is known to the operating system. Service options

Options tells the operating system which operations can be performed on the daemon while it is running.

This option is only used during the installation of the daemon.

Is the daemon enabled or not Enabled specifies whether a daemon should be installed, run or uninstalled. Disabled daemons are not installed, run or uninstalled. Windows-specific bindings (windows only) WinBindings is used to group together the windows-specific properties of the daemon. This property is totally ignored on other platforms. Event called when a daemon in instantiated OnCreateInstance is called whenever an instance of the daemon is created. This can be used for instance when a single TDaemon class is used to run several services, to correctly initialize the TDaemon. Log the status report to the system log LogStatusReport can be set to True to send the status reports also to the system log. This can be used to track the progress of the daemon. Collection of daemon definitions.

TDaemonDefs is the class of the global list of daemon definitions. It contains an item for each daemon in the application.

Normally it is not necessary to create an instance of TDaemonDefs manually. The global instance will create a collection and maintain it.

Create a new instance of a TDaemonDefs collection.

Create creates a new instance of the TDaemonDefs collection. It keeps the AOwner parameter for future reference and calls the inherited constructor.

Normally it is not necessary to create an instance of TDaemonDefs manually. The global instance will create a collection and maintain it.

Collection owner Item class. Return index of daemon definition IndexOfDaemonDef searches the collection for a instance with a name equal to DaemonName, and returns it's index. It returns -1 if no definition was found with this name. The search is case insensitive. Index of found definition, or -1 Daemon Name to search for. Find and return instance of daemon definition with given name. FindDaemonDef searches the list of daemon definitions and returns the instance whose name matches DaemonName. If no definition is found, Nil is returned. Matching TDaemonDef instance or Nil if none was found. Daemon name to search for. Find and return instance of daemon definition with given name.

FindDaemonDef searches the list of daemon definitions and returns the instance whose name matches DaemonName. If no definition is found, an exception is raised.

The FindDaemonDef call does not raise an error, but returns Nil instead.

If no definition is found, an exception is raised.
Matching TDaemonDef instance Daemon name to search for. Indexed access to TDaemonDef instances Daemons is the default property of TDaemonDefs, it gives access to the TDaemonDef instances in the collection. Zero-based index. Daemon mapper

The TCustomDaemonMapper class is responsible for mapping a daemon definition to an actual TDaemon instance. It maintains a collection with daemon definitions, which can be used to map the definition of a daemon to a TDaemon descendent class.

An IDE such as Lazarus can design a TCustomDaemonMapper instance visually, to help establish the relationship between various definitions and the actual instances that will be used to run the daemons.

The TCustomDaemonMapper class has no support for streaming. The class has support for streaming (and hence visual designing).

Create a new instance of TCustomDaemonMapper Create creates a new instance of a TCustomDaemonMapper. It creates the collection and then calls the inherited constructor. It should never be necessary to create a daemon mapper manually, the application will create a global TCustomDaemonMapper instance. Instance owner Clean up and destroy a TCustomDaemonMapper instance. Destroy frees the DaemonDefs collection and calls the inherited destructor. Collection of daemons DaemonDefs is the application's global collection of daemon definitions. This collection will be used to decide at runtime which TDaemon class must be created to run or install a daemon. Event called when the daemon mapper is created OnCreate is an event that is called when the TCustomDaemonMapper instance is created. It can for instance be used to dynamically create daemon definitions at runtime. OnDestroy OnUnInstall OnCreate OnDestroy Event called when the daemon mapper is freed. OnDestroy is called when the global daemon mapper instance is destroyed. it can be used to release up any resources that were allocated when the instance was created, in the OnCreate event. OnCreate OnInstall OnUnInstall OnCreate Event called when the daemons are executed. OnRun is the event called when the daemon application is executed to run the daemons (with command-line parameter '-r'). it is called exactly once. OnInstall OnUnInstall OnCreate OnDestroy Event called when the daemons are installed OnInstall is the event called when the daemon application is executed to install the daemons (with command-line parameter '-i' or '/install'). it is called exactly once. OnRun OnUnInstall OnCreate OnDestroy Event called when the daemons are uninstalled OnUnInstall is the event called when the daemon application is executed to uninstall the daemons (with command-line parameter '-u' or '/uninstall'). it is called exactly once. OnRun OnInstall OnCreate OnDestroy Daemon mapper for designing in IDE

TDaemonMapper is a direct descendent of , but introduces no new functionality. It's sole purpose is to make it possible for an IDE to stream the TDaemonMapper instance.

For this purpose, it overrides the Create constructor and tries to find a resource with the same name as the class name, and tries to stream the instance from this resource.

If the instance should not be streamed, the CreateNew constructor can be used instead.

CreateNew Create
Create a new TDaemonMapper instance and initializes it from streamed resources.

Create initializes a new instance of TDaemonMapper and attempts to read the component from resources compiled in the application.

If the instance should not be streamed, the CreateNew constructor can be used instead.

If no streaming system is found, or no resource exists for the class, an exception is raised. CreateNew
Instance owner Create a new TDaemonMapper instance without initialization CreateNew itializes a new instance of TDaemonMapper. In difference with the Create constructor, it does not attempt to read the component from a stream. Create Owner of the instance Ignored. Class of TCustomDaemonMapper TCustomDaemonMapperClass is the class of TCustomDaemonMapper. It is used in the call. Thread to run daemons in

TDaemonThread is the thread in which the daemons in the application are run. Each daemon is run in it's own thread.

It should not be necessary to create these threads manually, the class will take care of this.

Create a new thread Create creates a new thread instance. It initializes the Daemon property with the passed ADaemon. The thread is created suspended. Daemon instance which is running in this thread Run the daemon Execute starts executing the daemon and waits till the daemon stops. It also listens for control codes for the daemon. Check if a control message has arrived CheckControlMessage checks if a control message has arrived for the daemon and executes the appropriate daemon message. If the parameter WaitForMessage is True, then the routine waits for the message to arrive. If it is False and no message is present, it returns at once. If true, routine waits for message to arrive before returning. Stops the daemon StopDaemon attempts to stop the daemon using its method, and terminates the thread. True if the daemon was stopped succesfully. Pause the daemon

PauseDaemon attempts to stop the daemon using its method, and suspends the thread. It returns True if the attempt was succesful.

True if the daemon was succesfully paused Continue the daemon ContinueDaemon attempts to stop the daemon using its method. It returns True if the attempt was succesful. True if the daemon was succesfully restarted Shut down daemon ShutDownDaemon shuts down the daemon. This happens normally only when the system is shut down and the daemon didn't respond to the stop request. The return result is the result of the function. The thread is terminated by this method. The result of TDaemon.Shutdown Report the daemon status InterrogateDaemon simply calls for the daemon that is running in this thread. It always returns True. Always True. Daemon instance Daemon is the daemon instance which is running in this thread. GUI loop event mechanism TGuiLoopEvent is the main GUI loop event procedure prototype. It is called by the application instance in case the daemon has a visual part, which needs to handle visual events. It is run in the main application thread. Custom daemon application class

TCustomDaemonApplication is a TCustomApplication descendent which is the main application instance for a daemon. It handles the command-line and decides what to do when the application is started, depending on the command-line options given to the application, by calling the various methods.

It creates the necessary instances by checking the instance that contains the daemon maps.

TCustomApplication
Show an exception ShowException is overridden by TCustomDaemonApplication, it sends the exception message to the system log. Exception to show. Create daemon instance CreateDaemon is called whenever a instance must be created from a daemon definition, passed in DaemonDef. It initializes the TCustomDaemon instance, and creates a controller instance of type to control the daemon. Finally, it assigns the created daemon to the property. In case of an error, an exception may be raised. New TCustomDaemon instance. Daemon definition containing information to create a daemon. Stop all daemons StopDaemons sends the STOP control code to all daemons, or the SHUTDOWN control code in case Force is True. If True, send the SHUTDOWN control code Install all daemons. InstallDaemons installs all known daemons, i.e. registers them with the service manager on Windows. This method is called if the application is run with the -i or --install or /install command-line option. Run all daemons. RunDaemons runs (starts) all known daemons. This method is called if the application is run with the -r or --run methods. Uninstall all daemons UnInstallDaemons uninstalls all known daemons, i.e. deregisters them with the service manager on Windows. This method is called if the application is run with the -u or --uninstall or /uninstall command-line option. Create a component CreateForm creates an instance of InstanceClass and fills Reference with the class instance pointer. It's main purpose is to give an IDE a means of assuring that forms or datamodules are created on application startup: the IDE will generate calls for all modules that are auto-created. An exception may arise if the instance wants to stream itself from resources, but no resources are found. Class pointer of component instance to create Variable to store the instance pointer in. Event logging instance used for logging messages Logger contains a reference to the TEventLog instance that can be used to send messages to the system log. GUI main loop callback GUIMainLoop contains a reference to a method that can be called to process a main GUI loop. The procedure should return only when the main GUI has finished and the application should exit. It is called when the daemons are running. Handle of GUI loop main application window handle GuiHandle is the handle of a GUI window which can be used to run a message handling loop on. It is created when no GUIMainLoop procedure exists, and the application creates and runs a message loop by itself. GUIMainLoop Application mode RunMode indicates in which mode the application is running currently. It is set automatically by examining the command-line, and when set, one of InstallDaemons, RunDaemons or UnInstallDaemons is called. InstallDaemons RunDaemons UnInstallDaemons Class pointer for TCustomDaemonApplication Default descendent of CustomDaemonApplication TDaemonApplication is the default descendent that is used to run the daemon application. It is possible to register an alternative TCustomDaemonApplication class (using ) to run the application in a different manner. Exception used in all daemon application code EDaemon is the exception class used by all code in the DaemonApp unit. Application instance Application is the instance used by this application. The instance is created at the first invocation of this function, so it is possible to use to register an alternative TCustomDaemonApplication class to run the application. instance used by application Register a daemon mapper class RegisterDaemonMapper can be used to register an alternative class for the global daemonmapper. The daemonmapper will be used only when the application is being run, by the code, so registering an alternative mapping class should happen in the initialization section of the application units. New TCustomDaemonMapperClass class Register daemon RegisterDaemonClass must be called for each descendent that is used in the class: the class pointer and class name are used by the class to create a TCustomDaemon instance when a daemon is required. TCustomDaemon descendent class to be registered. Register alternative TCustomDaemonApplication class. RegisterDaemonApplicationClass can be used to register an alternative descendent which will be used when creating the global instance. Only the last registered class pointer will be used. New class pointer to be used Raise an EDaemon exception DaemonError raises an exception with message Msg or it formats the message using Fmt and Args. Message for the exception Formatting string for exception message Arguments to format for exception message No service mapper was found. An attempt was made to install a second service mapper No operation can be performed Duplicate service name Unknown daemon class requested The application failed to start the daemon Daemon status report log message The control code was not handled correctly A custom code was received Unable to start or contact the service manager Internal error: no daemon to report status for Internal error: no daemon definition to report status for Could not register window class A second application instance is created Names for various service statuses Status message Default daemon options DefaultDaemonOptions are the default options with which a daemon definition () is created. Description of the daemon Description is the description shown in the Windows service manager when managing this service. It is supplied to the windows service manager when the daemon is installed. Usage message displayed when writing help to the console Options message displayed when writing help to the console Install option message displayed when writing help to the console Uninstall option message displayed when writing help to the console Run option message displayed when writing help to the console Default class used when creating the application instance. AppClass can be set to the class of a descendant. When the function needs to create an application instance, this class will be used. If Application was already called, the value of AppClass will be ignored. Clean up the TCustomDaemonApplication instance Destroy cleans up the event log instance and then calls the inherited destroy. Display a help message ShowHelp displays a help message explaining the command-line options on standard output. Log a message to the system event log. Log logs Msg to the system event log with event type EventType. EventLog Event executed when the daemon is run. OnRun is triggered when the daemon application is run and no appropriate options (one of install, uninstall or run) was given. Event logger instance EventLog is the TEventLog instance which is used to log events to the system log with the Log method. It is created when the application instance is created, and destroyed when the application is destroyed. TEventLog Log