summaryrefslogtreecommitdiff
path: root/general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.h
blob: 04621b3ef1ccde6b1d2593494eddb5c5daeb37de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

// 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.

#pragma once

#include "ServiceBase.h"

class CSampleService : public CServiceBase
{
public:

    CSampleService(PWSTR pszServiceName,
        BOOL fCanStop = TRUE,
        BOOL fCanShutdown = TRUE,
        BOOL fCanPauseContinue = FALSE);
    void ConsoleRun();
    bool IsConsoleRun()
    {
        return m_runningInConsole;
    }
    void WriteEventLogEntry(PWSTR pszMessage, BYTE bLevel) override;
    virtual ~CSampleService(void);

protected:

    virtual void OnStart(DWORD dwArgc, PWSTR *pszArgv) override;
    virtual void OnStop() override;


private:
    PTP_WORK m_work = nullptr;
    bool m_runningInConsole = false;
};