//+---------------------------------------------------------------------------- // // // Microsoft Server Appliance Kit // // Synopsis: Definitions for class CChimeSvc // // Copyright (c) Microsoft Corporation. All rights reserved. // // //+---------------------------------------------------------------------------- #ifndef CHIMESERVICE_H #define CHIMESERVICE_H #include #include #include #include #include #include #define TRACE(x) #define TRACE1(x,y) #define ASSERT(x) #define ASSERTMSG(x,y) #include //+---------------------------------------------------------------------------- // // class CChimeSvc // // Synopsis: Class for CChimeSvc service // // //+---------------------------------------------------------------------------- // enumeration for command line. #define NUMSWITCH 2 enum g_switches { INSTALL, UNINSTALL }; bool g_rgCmdLine[NUMSWITCH]= { false,false }; //registry stuff #define CHIME_REGISTRY_SUBKEY TEXT("SOFTWARE\\Microsoft\\ServerAppliance\\Chime") #define CHIME_REGISTRY_INTERVAL TEXT("ChimeInterval") #define CHIME_REGISTRY_TYPE TEXT("ChimeType") class CChimeSvc { public: CChimeSvc(); ~CChimeSvc(); BOOL StartService(const TCHAR* pszServiceName); BOOL Install(const TCHAR* pszServiceName, const TCHAR* pszDisplayName, DWORD dwStartType = SERVICE_DEMAND_START, DWORD dwServiceType = SERVICE_WIN32_OWN_PROCESS); BOOL Uninstall(); protected: void SetStatus(DWORD dwState); BOOL InitializeService(); HRESULT Run(); // // Whether the service can be loaded // called in ServiceMain , if return false, will stop the service // BOOL CanLoad(); BOOL OnStop(); void OnShutdown(){}; // change this to virtual, if overwriting is needed void OnControlMessage(DWORD /*dwOpcode*/){}; // static member functions static void WINAPI ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv); static void WINAPI Handler(DWORD dwOpcode); static BOOL IsInstalled(const TCHAR* pszServiceName); public: TCHAR m_szServiceName[32]; // The short name of the service SERVICE_STATUS_HANDLE m_hServiceStatus; // the handle to report status SERVICE_STATUS m_Status; // The service status structure private: HANDLE m_hChimeChangeEvt; HANDLE m_hStopSvcEvt; DWORD m_dwChimeInterval; DWORD m_dwChimeType; // chime type is currently handled by the chime task. private: BOOL CreateChimeRegKeys(); void ReadChimeConfigFromRegistry(CComPtr &pTaskContext); DWORD ComputeTimeToChime(); public: static CChimeSvc* m_pThis; // Point to the only instance }; #endif