CNTService

CNTService - A NT service class using MFC.
This class introduces a very basic NT service class using MFC.
The class CNTService is devired from CWnd because this way we can make use of MFC's messages maps.

Short introduction to CNTService’s member functions:

BOOL ExecuteService()
Must be called from the application's main() function.
It looks for one of the following commandline parameters:

-i   Install the service (service will show up in the service list)
-u  Uninstall the service (service will be removed from the service list)
-s  Start the service
-e  Stop the service

when no parameter is given the StartDispatcher function is called, which connects the main thread to the service control manager. This means the service is executed.

virtual void Run()
This virtual member must be implemented by the derived class.
It contains the main code of the application. This member is automatically called when the service has been started.

virtual void Stop()
This virtual member notifies the service that it should stop.

virtual void Pause()
This virtual member notifies the service that it should pause.

virtual void Continue()
This virtual member notifies the paused service that it should resume.

virtual void Shutdown()
This virtual member notifies the service that the system is shutting down so the service can perform cleanup tasks.

void LogEvent(LPCTSTR pFormat, ...)
Write an event to the Windows event log.


The service will only run under Windows NT4/2000/XP and not Win95/98/ME.
To Start en Stop the service, go to the Windows Service Manager (Services) in the Control Panel.

If you have any improvements, additions or suggestions please let me know!


Download demo executable

Download source code
This class is part of the Pablo Software Solutions MFC Extension Package - Classes Edition
 

[Home] [Products] [Source Code] [Downloads] [Support]

© 2015 - Pablo Software Solutions
All rights reserved.