Method ServiceController():addController() Foundation

Registers a controller for sending control requests to a service.

:addController( <cName>        , ;
                [<cDispName>]  , ;
                [<cEXEName>]   , ;
                [<cUserAccnt>] , ;
                [<cPassWord>]  , ;
                [<cParam>]     , ;
                [<oLogger>]      ) --> lSuccess
This parameter contains the name of the service to be controlled by the service controller.
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>.
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.
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.
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.
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().
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.

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.


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.


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.