Method ServiceController():addController() Foundation

Registers a controller for sending control requests to a service.

Syntax
:addController( <cName>        , ;
                [<cDispName>]  , ;
                [<cEXEName>]   , ;
                [<cUserAccnt>] , ;
                [<cPassWord>]  , ;
                [<cParam>]     , ;
                [<oLogger>]      ) --> lSuccess
Parameters
<cName>
This parameter contains the name of the service to be controlled by the service controller.
<cDispName>
This parameter contains the name to be displayed for this service by service control applications. When this parameter is omitted it defaults to the contents of the parameter <cName>.
<cEXEName>
This parameter contains the full qualified name of the executable which implements the service, i.e. the name of the EXE including full path. If not set, the parameter defaults to the path and name of the current application.
<cUserAccnt>
This parameter contains the user account name under which the service is executed. If not set, the parameter defaults to an empty string. When an empty string or NIL is passed as user account, the service is executed under the LOCAL ACCOUNT. However, the user under whose account the service is executed must have the appropriate rights to log on as service. Please refer to the operating system's manual how to set the right Log on as Service.
<cPass>
This parameter contains the password belonging to the account under which the service starts. If not set the parameter defaults to an empty string which is the correct value when the service is executed under LOCAL ACCOUNT.
<cParam>
This parameter contains a string containing the command line parameters that are passed to the service when it is started. The :main() method of the service class receives command line parameters as an array of strings. By default <cParam> contains an empty string and no parameters are passed to :main().
<oLogger>
This parameter contains an object of a class which has to implement the method :write(). With this it is possible to log internal messages and process them in any desired way.
Return

The method calls the instance method :logSuccess() and returns .T. (true) when a new controller instance is created, otherwise it calls the instance method :logError() and .F. (false) is returned. This means that a controller with the passed name already exists.

Description

One application may implement the control mechanism of an abitrary number of services. However, it must be ensured that there is only one controller for each service. This is done by the interface :addController() which registers a controller for the service whose names are passed. The method does not return the instance of the class but indicates whether a new service controller is created (return .T.) or if it already exists (return .F.). The controller instance can then be accessed by the method :getUpdatedControl().

When the controller is successfully registered, the service may be controlled by the class methods :install(), :start(), :stop(), :pause(), :continue(), and :uninstall(). All of these methods expect the name of the service to control.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.