The following script defines an NtService which can be used to provide a service on Windows NT.
# File: ntseg.cpl
#
# $Id: ntseg.htm,v 1.5 2002/01/29 14:48:31 ibi Exp $ (c) 1999 Carapace Communications Ltd
#
# defines an NtService object which can be run as an NT Service
# using Carapace
#
# The service simply logs some text every minute. To show what has
# happened, each of the methods writes to the log file
(class NtService
(interface
(properties
(name String)
(log Log)
(active Event)
)
(methods
(NIL NtService ( (nm String) ) )
(NIL run ( (args String) ) )
(NIL stop ( (gracePeriod Integer) ) )
(NIL shutdown ( (gracePeriod Integer) ) )
)
)
)
(defun NIL NtService::NtService ( (nm String) )
(this.name nm)
(this.log (create Log (join (list nm ".log"))))
(this.active (create Event))
(this.log.print "service created")
)
(defun NIL NtService::run ( (args String) )
(this.log.print "service started")
(while 1
(this.log.print "service running")
# wait on the event, finishing if the event is set
(if (this.active.wait 60000) (break))
)
(this.log.print "service 'run' function finished")
)
(defun NIL NtService::stop ( (gracePeriod Integer) )
(this.active.set)
(this.log.print "service stopped")
)
(defun NIL NtService::shutdown ( (gracePeriod Integer) )
(this.active.set)
(this.log.print "service shut down")
)
| Contents | Index | Current topic: NT Services | Related topics: objects |