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.

101 lines
2.5 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright 1995 - 1997 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. #ifndef _SERVICE_H
  9. #define _SERVICE_H
  10. // Forward declarations
  11. class CSnapin;
  12. #define SCOPE_ITEM 111
  13. #define RESULT_ITEM 222
  14. // Internal structure used for cookies
  15. struct FOLDER_DATA
  16. {
  17. wchar_t* szName;
  18. wchar_t* szSize;
  19. wchar_t* szType;
  20. FOLDER_TYPES type;
  21. };
  22. struct RESULT_DATA
  23. {
  24. DWORD itemType; // used for debug purpose only
  25. FOLDER_TYPES parentType;
  26. wchar_t* szName;
  27. wchar_t* szSize;
  28. wchar_t* szType;
  29. };
  30. class CFolder
  31. {
  32. DWORD itemType; // Used for debug purpose only. This should be the first
  33. // member. The class should not have any virtual fuctions.
  34. friend class CSnapin;
  35. friend class CComponentDataImpl;
  36. public:
  37. // UNINITIALIZED is an invalid memory address and is a good cookie initializer
  38. CFolder()
  39. {
  40. itemType = SCOPE_ITEM; // used for debug purpose only
  41. m_cookie = UNINITIALIZED;
  42. m_enumed = FALSE;
  43. m_pScopeItem = NULL;
  44. m_type = NONE;
  45. m_pszName = NULL;
  46. };
  47. ~CFolder() { delete m_pScopeItem; CoTaskMemFree(m_pszName); };
  48. // Interface
  49. public:
  50. BOOL IsEnumerated() { return m_enumed; };
  51. void Set(BOOL state) { m_enumed = state; };
  52. void SetCookie(MMC_COOKIE cookie) { m_cookie = cookie; }
  53. FOLDER_TYPES GetType() { ASSERT(m_type != NONE); return m_type; };
  54. BOOL operator == (const CFolder& rhs) const { return rhs.m_cookie == m_cookie; };
  55. BOOL operator == (MMC_COOKIE cookie) const { return cookie == m_cookie; };
  56. void SetName(LPWSTR pszIn)
  57. {
  58. UINT len = wcslen(pszIn) + 1;
  59. LPWSTR psz = (LPWSTR)CoTaskMemAlloc(len * sizeof(WCHAR));
  60. if (psz != NULL)
  61. {
  62. wcscpy(psz, pszIn);
  63. CoTaskMemFree(m_pszName);
  64. m_pszName = psz;
  65. }
  66. }
  67. HSCOPEITEM GetItemID()
  68. {
  69. return m_pScopeItem->ID;
  70. }
  71. // Implementation
  72. private:
  73. void Create(LPWSTR szName, int nImage, int nOpenImage,
  74. FOLDER_TYPES type, BOOL bHasChildren = FALSE);
  75. // Attributes
  76. private:
  77. LPSCOPEDATAITEM m_pScopeItem;
  78. MMC_COOKIE m_cookie;
  79. BOOL m_enumed;
  80. FOLDER_TYPES m_type;
  81. LPOLESTR m_pszName;
  82. };
  83. #endif