Leaked source code of windows server 2003
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.

147 lines
4.1 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CService.h
  7. //
  8. // Description:
  9. // Header file for CService class.
  10. //
  11. // The CService class is provides several routines that aid in
  12. // configuring a service.
  13. //
  14. // Implementation Files:
  15. // CService.cpp
  16. //
  17. // Maintained By:
  18. // Ozan Ozhan (OzanO) 19-JAN-2002
  19. // Vij Vasu (Vvasu) 13-MAR-2000
  20. //
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Make sure that this file is included only once per compile path.
  23. #pragma once
  24. //////////////////////////////////////////////////////////////////////////
  25. // Include Files
  26. //////////////////////////////////////////////////////////////////////////
  27. // For basic types
  28. #include <windows.h>
  29. // For HINF
  30. #include <setupapi.h>
  31. // For the string class
  32. #include "CommonDefs.h"
  33. // For the CStr class.
  34. #include "CStr.h"
  35. //////////////////////////////////////////////////////////////////////////
  36. // Forward declarations
  37. //////////////////////////////////////////////////////////////////////////
  38. class CStatusReport;
  39. //////////////////////////////////////////////////////////////////////////////
  40. //++
  41. //
  42. // class CService
  43. //
  44. // Description:
  45. // The CService class is provides several routines that aid in
  46. // configuring a service.
  47. //
  48. //--
  49. //////////////////////////////////////////////////////////////////////////////
  50. class CService
  51. {
  52. public:
  53. //////////////////////////////////////////////////////////////////////////
  54. // Constructors and destructors
  55. //////////////////////////////////////////////////////////////////////////
  56. // Constructor.
  57. CService(
  58. const WCHAR * pszNameIn
  59. )
  60. : m_strName( pszNameIn)
  61. , m_scWin32ExitCode( ERROR_SUCCESS )
  62. , m_scServiceExitCode( ERROR_SUCCESS )
  63. {
  64. }
  65. // Destructor
  66. ~CService() {}
  67. //////////////////////////////////////////////////////////////////////////
  68. // Public member functions
  69. //////////////////////////////////////////////////////////////////////////
  70. // Create this service in the SCM database.
  71. void Create( HINF hInfHandleIn );
  72. // Erase this service from the SCM database.
  73. void Cleanup( HINF hInfHandleIn );
  74. // Start this service.
  75. void Start(
  76. SC_HANDLE hServiceControlManagerIn
  77. , bool fWaitForServiceStartIn = true
  78. , ULONG ulQueryIntervalMilliSecIn = 500
  79. , UINT cQueryCountIn = 10
  80. , CStatusReport * pStatusReportIn = NULL
  81. );
  82. // Stop this service.
  83. void Stop(
  84. SC_HANDLE hServiceControlManagerIn
  85. , ULONG ulQueryIntervalMilliSecIn = 500
  86. , UINT cQueryCountIn = 10
  87. , CStatusReport * pStatusReportIn = NULL
  88. );
  89. // Return the m_scWin32ExitCode
  90. DWORD GetWin32ExitCode( void )
  91. {
  92. return m_scWin32ExitCode;
  93. }
  94. // Return the m_scServiceSpecificExitCode
  95. DWORD GetServiceExitCode( void )
  96. {
  97. return m_scServiceExitCode;
  98. }
  99. // Enable the service
  100. private:
  101. //////////////////////////////////////////////////////////////////////////
  102. // Private member functions
  103. //////////////////////////////////////////////////////////////////////////
  104. DWORD ScStartService( SC_HANDLE hServiceIn );
  105. // Copy constructor
  106. CService( const CService & );
  107. // Assignment operator
  108. const CService & operator =( const CService & );
  109. //////////////////////////////////////////////////////////////////////////
  110. // Private data
  111. //////////////////////////////////////////////////////////////////////////
  112. // The name of this service.
  113. CStr m_strName;
  114. DWORD m_scWin32ExitCode;
  115. DWORD m_scServiceExitCode;
  116. }; // class CService