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.

169 lines
5.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990, 1991 **/
  4. /**********************************************************************/
  5. /*
  6. lmoesvc.hxx
  7. This file contains the class declarations for the SERVICE_ENUM
  8. enumerator class and its associated iterator class.
  9. The SERVICE_ENUM class is used to enumerate the services installed
  10. on a target (possibly remote) server.
  11. NOTE: This class uses the Win32 Service Control API.
  12. FILE HISTORY:
  13. KeithMo 17-Jan-1992 Created.
  14. KeithMo 31-Jan-1992 Changes from code review on 29-Jan-1992
  15. attended by ChuckC, EricCh, TerryK.
  16. KeithMo 04-Jun-1992 Handle NT & LM servers differently.
  17. KeithMo 11-Nov-1992 Added DisplayName goodies.
  18. */
  19. #ifndef _LMOESVC_HXX
  20. #define _LMOESVC_HXX
  21. //
  22. // NOTE!
  23. //
  24. // We must enumerate the servers differently for NT vs LM servers.
  25. // To make life somewhat simpler on the client side, we'll map the
  26. // NT and LM enumerations to a common structure (ENUM_SVC_STATUS).
  27. // It is VERY IMPORTANT that sizeof(ENUM_SVC_STATUS) be <=
  28. // sizeof(ENUM_SERVICE_STATUS).
  29. //
  30. typedef struct _ENUM_SVC_STATUS
  31. {
  32. const TCHAR * pszServiceName;
  33. const TCHAR * pszDisplayName;
  34. ULONG nCurrentState;
  35. ULONG nControlsAccepted;
  36. ULONG nStartType;
  37. } ENUM_SVC_STATUS;
  38. /*************************************************************************
  39. NAME: SERVICE_ENUM
  40. SYNOPSIS: This is class is used to enumerate installed services.
  41. INTERFACE: SERVICE_ENUM - Class constructor.
  42. ~SERVICE_ENUM - Class destructor.
  43. CallAPI() - Invoke the enumeration API.
  44. PARENT: LOC_LM_ENUM
  45. HISTORY:
  46. KeithMo 17-Jan-1992 Created.
  47. **************************************************************************/
  48. DLL_CLASS SERVICE_ENUM : public LOC_LM_ENUM
  49. {
  50. private:
  51. UINT _ServiceType;
  52. BOOL _fIsNtServer;
  53. NLS_STR _nlsGroupName;
  54. virtual APIERR CallAPI( BYTE ** ppbBuffer,
  55. UINT * pcEntriesRead );
  56. APIERR EnumNtServices( BYTE ** ppbBuffer,
  57. UINT * pcEntriesRead );
  58. APIERR EnumLmServices( BYTE ** ppbBuffer,
  59. UINT * pcEntriesRead );
  60. VOID CountServices( BYTE * pbBuffer,
  61. UINT * pcServices,
  62. UINT * pcbServiceNames );
  63. VOID MapLmStatusToNtState( DWORD dwLmStatus,
  64. ULONG * pnCurrentState,
  65. ULONG * pnControlsAccepted );
  66. public:
  67. SERVICE_ENUM( const TCHAR * pszServer,
  68. BOOL fIsNtServer,
  69. UINT ServiceType = SERVICE_WIN32,
  70. const TCHAR * pszGroupName = NULL );
  71. ~SERVICE_ENUM();
  72. }; // class SERVICE_ENUM
  73. /*************************************************************************
  74. NAME: SERVICE_ENUM_OBJ
  75. SYNOPSIS: This is basically the return type from the
  76. SERVICE_ENUM_ITER iterator.
  77. INTERFACE: QueryServiceName - Returns the name of the service.
  78. QueryCurrentState - Returns the current state of
  79. the service (SERVICE_*).
  80. QueryControlsAccepted - Bitmask indicating which operations
  81. (stop,pause,continue) may be
  82. performed (SERVICE_ACCEPT_*).
  83. PARENT: ENUM_OBJ_BASE
  84. NOTE: The QueryCurrentState & QueryControlsAccepted accessor
  85. return WIN32-style values, *not* LM-style values!
  86. HISTORY:
  87. KeithMo 17-Jan-1992 Created.
  88. **************************************************************************/
  89. DLL_CLASS SERVICE_ENUM_OBJ : public ENUM_OBJ_BASE
  90. {
  91. friend class SERVICE_ENUM_ITER;
  92. protected:
  93. //
  94. // Provide properly casted buffer query/set methods.
  95. //
  96. const ENUM_SVC_STATUS * QueryBufferPtr( VOID ) const
  97. { return (const ENUM_SVC_STATUS *)ENUM_OBJ_BASE::QueryBufferPtr(); }
  98. VOID SetBufferPtr( const ENUM_SVC_STATUS * pBuffer )
  99. { ENUM_OBJ_BASE::SetBufferPtr( (const BYTE *)pBuffer ); }
  100. public:
  101. //
  102. // Accessors.
  103. //
  104. DECLARE_ENUM_ACCESSOR( QueryServiceName, const TCHAR *, pszServiceName );
  105. DECLARE_ENUM_ACCESSOR( QueryDisplayName, const TCHAR *, pszDisplayName );
  106. DECLARE_ENUM_ACCESSOR( QueryCurrentState, UINT, nCurrentState );
  107. DECLARE_ENUM_ACCESSOR( QueryControlsAccepted, UINT, nControlsAccepted );
  108. DECLARE_ENUM_ACCESSOR( QueryStartType, UINT, nStartType );
  109. BOOL IsEnabled( VOID ) const
  110. { return QueryStartType() != SERVICE_DISABLED; }
  111. }; // class SERVICE_ENUM_OBJ
  112. DECLARE_LM_ENUM_ITER_OF( SERVICE, ENUM_SVC_STATUS )
  113. #endif // _LMOESVC_HXX