CServiceManager

Provides enhanced remote control functions for Windows NT Services.

[ WhoSLocking | Source | Keywords | Summary | Ancestors | All Members | Descendants ]

Quick Index

DESCRIPTION
USAGE
EXAMPLE
ADMINISTRATIVE
SEE ALSO

Class Summary

class CServiceManager

{

public:
CServiceManager();
~CServiceManager();
BOOL Open(LPCTSTR lpszMachineName, LPCTSTR lpszServiceName);
BOOL StartService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName , BOOL bStartDependents );
BOOL StopService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName , BOOL bStopDependents );
BOOL QueryService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName );
BOOL ListServices(LPCTSTR lpszMachineName );
BOOL PrintServiceInfo(int nCount, SERVICE_STATUS *ServiceStatus, LPCTSTR lpszServiceName, LPCTSTR lpszDisplayName, LPQUERY_SERVICE_CONFIG lpServiceConfig );
BOOL OpenServiceControlManager(LPCTSTR lpszMachineName );
BOOL OpenService(LPCTSTR lpszServiceName );
protected:
}; // CServiceManager

Back to the top of CServiceManager


DESCRIPTION

This class enhanced remote control functions for Windows NT Services.

Back to the top of CServiceManager


USAGE

To use this class:

Note: By default, this class prints log/error messages in stdout. To change this behavior, you must derive this class and override functions Print() and PrintServiceInfo() with your own in the derived class.

Back to the top of CServiceManager


EXAMPLE

    CServiceManager oServiceManager;

CString szMyRemoteMachine = "\\\\remotename"; CString szMyServiceName = "MyService";

if (oServiceManager.OpenService(szMyRemoteMachine, szMyServiceName)) { if (oServiceManager.StartService(NULL, // Use currently opened machine NULL, // Use currently opened service TRUE // Start dependent services )) {

cout << "Service started!\n";

} else {

cerr << "Cannot start service " << szMyServiceName << " on host " << szMyRemoteMachine << "\n";

} } else {

cerr << "Cannot connect to service " << szMyServiceName << " on host " << szMyRemoteMachine << "\n";

}

Back to the top of CServiceManager


ADMINISTRATIVE

Author Emmanuel KARTMANN

Date Monday 12/6/99

Back to the top of CServiceManager


SEE ALSO

Back to the top of CServiceManager


CServiceManager();

Purpose: create an instance of the class

Parameters: none (C++ constructor)

Return value : none (C++ constructor)

Description :

    CServiceManager();

Back to the top of CServiceManager


~CServiceManager();

Purpose: delete an instance of the class

Parameters: none (C++ destructor)

Return value : none (C++ destructor)

Description :

    virtual ~CServiceManager();

Back to the top of CServiceManager


BOOL Open(LPCTSTR lpszMachineName, LPCTSTR lpszServiceName);

Purpose: open a service (possibly remote)

Parameters:

in lpszMachineName
name of the remote machine
in lpszServiceName
name of the service (internal name OR display name)

Return value : BOOL = TRUE for success, FALSE otherwise

Description :

    BOOL Open(LPCTSTR lpszMachineName, LPCTSTR lpszServiceName);

Back to the top of CServiceManager


BOOL StartService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName , BOOL bStartDependents );

Purpose: start a service (possibly remote)

Parameters:

in lpszMachineName
name of the remote machine, or NULL
in lpszServiceName
name of the service (internal name OR display name), or NULL
in bStartDependents
flag, TRUE if dependent service must be started too.

Return value : BOOL = TRUE for success, FALSE otherwise

Description : If any of the parameters are NULL, this function reuses the currently open SCM/Service.

    BOOL StartService(LPCTSTR lpszMachineName = NULL, LPCTSTR lpszServiceName = NULL, BOOL bStartDependents = FALSE);

Back to the top of CServiceManager


BOOL StopService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName , BOOL bStopDependents );

Purpose: stop a service (possibly remote)

Parameters:

in lpszMachineName
name of the remote machine
in lpszServiceName
name of the service (internal name OR display name)
in bStopDependents
flag, TRUE if dependent service must be stopped too.

Return value : BOOL = TRUE for success, FALSE otherwise

Description : If any of the parameters are NULL, this function reuses the currently open SCM/Service.

    BOOL StopService(LPCTSTR lpszMachineName = NULL, LPCTSTR lpszServiceName = NULL, BOOL bStopDependents = FALSE);

Back to the top of CServiceManager


BOOL QueryService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName );

Purpose: fetch service information (possibly remote)

Parameters:

in lpszMachineName
name of the remote machine, or NULL
in lpszServiceName
name of the service (internal name OR display name), or NULL

Return value : BOOL = TRUE for success, FALSE otherwise

Description : If any of the parameters are NULL, this function reuses the currently open SCM/Service.

    BOOL QueryService(LPCTSTR lpszMachineName = NULL, LPCTSTR lpszServiceName = NULL);

Back to the top of CServiceManager


BOOL ListServices(LPCTSTR lpszMachineName );

Purpose: list the services installed on a machine (possibly remote)

Parameters:

in lpszMachineName
name of the remote machine, or NULL

Return value : BOOL = TRUE for success, FALSE otherwise

Description : If the parameter is NULL, this function reuses the currently open SCM.

    BOOL ListServices(LPCTSTR lpszMachineName = NULL);

Back to the top of CServiceManager


BOOL PrintServiceInfo(int nCount, SERVICE_STATUS *ServiceStatus, LPCTSTR lpszServiceName, LPCTSTR lpszDisplayName, LPQUERY_SERVICE_CONFIG lpServiceConfig );

Purpose:

Parameters:

in nCount
service number
in lpszServiceName
service name (internal name)
in lpszDisplayName
service display name
in ServiceStatus
pointer
in lpServiceConfig
pointer to service configuration info

Return value : BOOL = TRUE for success, FALSE otherwise

Description : Derive this class and override this function if you don't want to print data in stdout.

    virtual BOOL PrintServiceInfo(int nCount, SERVICE_STATUS *ServiceStatus, LPCTSTR lpszServiceName, LPCTSTR lpszDisplayName, LPQUERY_SERVICE_CONFIG lpServiceConfig = NULL);

Back to the top of CServiceManager


BOOL OpenServiceControlManager(LPCTSTR lpszMachineName );

Purpose: open SCM on a machine (possibly remote)

Parameters:

in lpszMachineName
name of the remote machine, or NULL

Return value : BOOL = TRUE for success, FALSE otherwise

Description :

    BOOL OpenServiceControlManager(LPCTSTR lpszMachineName = NULL);

Back to the top of CServiceManager


BOOL OpenService(LPCTSTR lpszServiceName );

Purpose: open a service on a machine

Parameters:

in lpszServiceName
name of the service, or NULL

Return value : BOOL = TRUE for success, FALSE otherwise

Description :

    BOOL OpenService(LPCTSTR lpszServiceName = NULL);

Back to the top of CServiceManager


All Members

public:
BOOL Open(LPCTSTR lpszMachineName, LPCTSTR lpszServiceName);
BOOL StartService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName , BOOL bStartDependents );
BOOL StopService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName , BOOL bStopDependents );
BOOL QueryService(LPCTSTR lpszMachineName , LPCTSTR lpszServiceName );
BOOL ListServices(LPCTSTR lpszMachineName );
BOOL PrintServiceInfo(int nCount, SERVICE_STATUS *ServiceStatus, LPCTSTR lpszServiceName, LPCTSTR lpszDisplayName, LPQUERY_SERVICE_CONFIG lpServiceConfig );
BOOL OpenServiceControlManager(LPCTSTR lpszMachineName );
BOOL OpenService(LPCTSTR lpszServiceName );
protected:

Back to the top of CServiceManager


Ancestors

Class does not inherit from any other class.

Back to the top of CServiceManager


Descendants

Class is not inherited by any others.

Back to the top of CServiceManager


Generated from source by the Cocoon utilities on Thu Feb 10 12:02:41 2000 .

Report problems to jkotula@stratasys.com