Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.9 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. CNTSERV.H
  5. Abstract:
  6. History:
  7. a-davj 20-June-96 Created.
  8. ivanbrug 30-Aug-2000 modified for SvcHost
  9. --*/
  10. #ifndef _CNTSERV_H_
  11. #define _CNTSERV_H_
  12. #define DEFAULT_WAIT_HINT 30000
  13. class CNtService {
  14. public:
  15. CNtService(DWORD ControlAccepted);
  16. ~CNtService();
  17. // Starts up the service. This must be called to start the service.
  18. //==================================================================
  19. virtual DWORD Run(LPWSTR pszServiceName,
  20. DWORD dwNumServicesArgs,
  21. LPWSTR *lpServiceArgVectors,
  22. PVOID lpData);
  23. // This MUST be overridden since this is where the actual work is done
  24. //====================================================================
  25. virtual DWORD WorkerThread() = 0;
  26. // This MUST be overridden to signal the worker thread to exit its routine
  27. //=========================================================================
  28. virtual void Stop(BOOL bSystemShutDownCalled) = 0;
  29. // If there is some lengthy initialization, it should be done by
  30. // overriding this routine.
  31. //===============================================================
  32. virtual BOOL Initialize(DWORD dwNumServicesArgs,
  33. LPWSTR *lpServiceArgVectors){return TRUE;};
  34. virtual void FinalCleanup(){};
  35. // These routines are optional and should be overridden if the features
  36. // are desired. Note that supporting Pause and Continue also require a
  37. // call to SetPauseContinue()
  38. //=====================================================================
  39. virtual void Pause(){return;};
  40. virtual void Continue(){return;};
  41. // dumps messages to the event log. Can be overriden if there is
  42. // another diagnostic in place.
  43. //===============================================================
  44. virtual VOID Log(LPCTSTR lpszMsg);
  45. private:
  46. static DWORD WINAPI _HandlerEx(DWORD dwControl,
  47. DWORD dwEventType,
  48. LPVOID lpEventData,
  49. LPVOID lpContext);
  50. BOOL m_bStarted;
  51. TCHAR * m_pszServiceName;
  52. DWORD m_dwCtrlAccepted;
  53. SERVICE_STATUS ssStatus; // current status of the service
  54. SERVICE_STATUS_HANDLE sshStatusHandle;
  55. virtual DWORD WINAPI HandlerEx(DWORD dwControlCode,
  56. DWORD dwEventType,
  57. LPVOID lpEventData,
  58. LPVOID lpContext);
  59. protected:
  60. // this might come in handy if the derived class needs to communicate
  61. // with the SCM.
  62. //===================================================================
  63. BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
  64. DWORD dwWin32ExitCode, DWORD dwCheckPoint, DWORD dwWaitHint);
  65. };
  66. #endif