campo-sirio/SSAservice/SSAservice.h

48 lines
1.6 KiB
C++

/****************************** Module Header ******************************\
* Module Name: SampleService.h
* Project: CppWindowsService
* Copyright (c) Microsoft Corporation.
*
* Provides a sample service class that derives from the service base class -
* CServiceBase. The sample service logs the service start and stop
* information to the Application event log, and shows how to run the main
* function of the service in a thread pool worker thread.
*
* This source is subject to the Microsoft Public License.
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
* All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
#pragma once
#include "ServiceBase.h"
class CSSAservice : public CServiceBase
{
LPCTSTR _agent;
public:
CSSAservice(LPCTSTR pszServiceName,
BOOL fCanStop = TRUE,
BOOL fCanShutdown = TRUE,
BOOL fCanPauseContinue = FALSE);
void ServiceLoop(void);
virtual ~CSSAservice();
protected:
virtual void OnStart(DWORD dwArgc, PWSTR *pszArgv);
virtual void OnStop();
BOOL FindAgent(HANDLE& hProcess, DWORD& pid) const;
BOOL FindOrCreateAgent(HANDLE& hProcess, DWORD& pid) const;
void CheckDirectory() const;
private:
BOOL m_fStopping;
HANDLE m_hStoppedEvent;
};