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.

145 lines
5.0 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // File: SETUPSVC.HXX
  4. //
  5. // Contents: CService class which allows services to be configured,
  6. // setup, or removed.
  7. //
  8. // Synoposis: CService is a smart wrapper class arounf Win32 Service
  9. // configuration APIs which allows the class to contain
  10. // the resources such as lock on Service Controller
  11. // database such that the destructor automatically
  12. // releases them
  13. //
  14. // Classes: CService
  15. //
  16. // Functions: ConfigDfs
  17. // StartDfs
  18. // ConfigDfsService
  19. //
  20. // History: May 19, 1993 AlokS Created
  21. //
  22. //-------------------------------------------------------------------
  23. #ifndef _SETUPSVC_HXX_
  24. #define _SETUPSVC_HXX_
  25. //+------------------------------------------------------------------
  26. //
  27. // Class: CService (cdsSC)
  28. //
  29. // Purpose: Helper class for dealing with Service Controller
  30. //
  31. // Interface: CService::CService() = Constructor
  32. // CService::~CService() = Destructor
  33. // CService::Init() = Initializes the class
  34. // CService::_CreateService() = Install a Win32 Service
  35. // CService::_OpenService() = Open an existing service
  36. // CService::_CloseService() = Close all resources associated with
  37. // the service
  38. // CService::_DeleteService() = Remove a Win32 Service
  39. // CService::_DisableService() = Disables a Win32 Service
  40. // CService::_StartService() = Start an existing service
  41. // CService::_StopService() = Stop an existing service
  42. // CService::_ConfigService() = Combo operation. Create if
  43. // not present else reconfigure it
  44. //
  45. // History: May 20, 1993 AlokS Created
  46. //
  47. // Notes: This is a smart wrapper class for Service APIs but it is not
  48. // multi-thread safe.
  49. //
  50. //-------------------------------------------------------------------
  51. #define DSSCDebugOut(x)
  52. // Cairo Services should all belong to this group
  53. class CService
  54. {
  55. public:
  56. // Constructor
  57. CService();
  58. // Destructor
  59. ~CService();
  60. // Initialize
  61. DWORD Init();
  62. // Get at service database Manager
  63. SC_HANDLE QueryScManager() { return _schSCManager; };
  64. // Get at service handle created or modified
  65. SC_HANDLE QueryService() { return _scHandle;};
  66. // Create a service
  67. DWORD _CreateService( const LPWSTR lpwszServiceName,
  68. const LPWSTR lpwszDisplayName,
  69. DWORD fdwDesiredAccess,
  70. DWORD fdwServiceType,
  71. DWORD fdwStartType,
  72. DWORD fdwErrorControl,
  73. const LPWSTR lpwszBinaryPathName,
  74. const LPWSTR lpszLoadOrderGroup,
  75. const LPDWORD lpdwTagID,
  76. const LPWSTR lpwszDependencies,
  77. const LPWSTR lpwszServiceStartName,
  78. const LPWSTR lpwszPassword);
  79. // Open Service
  80. DWORD _OpenService( const LPWSTR lpwszServiceName,
  81. DWORD fdwDesiredAccess
  82. );
  83. // query status
  84. DWORD _QueryServiceStatus(LPSERVICE_STATUS ss);
  85. // Close Service
  86. void _CloseService( );
  87. // Start Service
  88. DWORD _StartService( const LPWSTR lpwszServiceName
  89. );
  90. // Stop Service
  91. DWORD _StopService( const LPWSTR lpwszServiceName
  92. );
  93. // Delete Service
  94. DWORD _DeleteService(const LPWSTR lpwszServiceName);
  95. // Disable Service
  96. DWORD _DisableService(const LPWSTR lpwszServiceName);
  97. // Config Service
  98. DWORD _ConfigService( DWORD fdwServiceType,
  99. DWORD fdwStartType,
  100. DWORD fdwErrorControl,
  101. const LPWSTR lpwszBinaryPathName,
  102. const LPWSTR lpwszLoadOrderGroup,
  103. const LPWSTR lpwszDependencies,
  104. const LPWSTR lpwszServiceStartName,
  105. const LPWSTR lpwszPassword,
  106. const LPWSTR lpwszDisplayName,
  107. const LPWSTR lpwszServiceName
  108. );
  109. private:
  110. // handle of service control manager database
  111. SC_HANDLE _schSCManager;
  112. // Handle of service being created/modified
  113. SC_HANDLE _scHandle;
  114. };
  115. // The following are useful for starting DFS Service
  116. #define SERVICE_WAIT_TIME (1000*6) // 6 seconds
  117. #define MAX_SERVICE_WAIT_RETRIES (60) // 6*60 = 6 minute
  118. #define DFS_VERSION_NUMBER 1381
  119. DWORD ConfigDfs();
  120. DWORD ConfigDfsService();
  121. DWORD StartDfs();
  122. #endif // _SETUPSVC_HXX_