This repository provides a C++ template for creating a Windows Service, with the necessary files to install, uninstall, and control the service.
- C++ Windows Service template
- Service Installer for easy installation and removal
- Base classes for creating custom Windows Services
- Logging and error handling
- WindowsService.cpp: Main file containing the
wmain
function to install, uninstall, or run the service. - WindowsService.h: Header file for the
CWindowsServiceImpl
class derived fromCServiceBase
. - ServiceBase.h: Header file for the
CServiceBase
class, which provides a base class for a service that will exist as part of a service application.
- Clone the repository and navigate to the project directory.
- Customize the
CWindowsServiceImpl
class inWindowsService.h
to implement your desired service behavior. - Compile the project with your preferred C++ compiler.
- Install the service by running the compiled executable with the
-install
or/install
parameter:<your_executable_name> -install
- Remove the service by running the compiled executable with the
-remove
or/remove
parameter:<your_executable_name> -remove
- Start, stop, or control the service using the Windows Services control panel or command-line tools like
sc
ornet
.
This project is open source and available under the MIT License.