
#pragma once

#include <windows.h>
#include <winsvc.h>

//Error codes

#define SVC_OK (DWORD)0
#define SVC_NOT_CREATE (DWORD)1
#define SVC_NOT_START (DWORD)2
#define SVC_NOT_INIT (DWORD)3
#define SVC_ERROR_SCMANAGER (DWORD)4
#define SVC_ERROR_CREATE (DWORD)5
#define SVC_ERROR_START (DWORD)6
#define SVC_ERROR_OPEN (DWORD) 7
#define SVC_ERROR_STOP (DWORD)8
#define SVC_ERROR_UNLOAD (DWORD) 9


class CService
{
public:
	//Constructor
	CService(void);
	CService(LPTSTR _lpFilePath,LPTSTR _lpServiceName,LPTSTR _lpDisplayName,DWORD _dwStartType);
	//Destructor
	~CService(void);
	
	//init function
	SC_HANDLE InitSvc(LPTSTR _lpFilePath,LPTSTR _lpServiceName,LPTSTR _lpDisplayName,DWORD _dwStartType);
	DWORD CreateSvc(SC_HANDLE hSCManager);  //create service
	DWORD UnloadSvc(SC_HANDLE hSCManager);  //unload service
	DWORD StartSvc(SC_HANDLE hSCManager);  //start service
	DWORD StopSvc(SC_HANDLE hSCManager);   //stop service


	BOOL   IsInit(void); //check if service is init
	BOOL   IsLoaded(void); //check if service is loaded
	BOOL   IsStarted(void); //check if service is started

	

private:
	
	LPTSTR lpFilePath; //driver file path
	LPTSTR lpServiceName; //service name
	LPTSTR lpDisplayName; //service's dos name

	DWORD dwStartType; //start type

	SC_HANDLE hService; //service's handle
	
	// Status variables
	BOOL init; 
	BOOL loaded;
	BOOL started;	

};
