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.

93 lines
2.1 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) Microsoft Corporation, 1995 - 1999
  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. #include "stdafx.h"
  9. CFolder::~CFolder()
  10. {
  11. if (m_pScopeItem)
  12. {
  13. delete m_pScopeItem;
  14. }
  15. CoTaskMemFree(m_pszName);
  16. if (m_hCertType != NULL)
  17. {
  18. CACloseCertType(m_hCertType);
  19. }
  20. // dont close the m_hCAInfo if this is a result folder, it is the same as the scope folders m_hCAInfo
  21. else if (m_hCAInfo != NULL)
  22. {
  23. CACloseCA(m_hCAInfo);
  24. }
  25. }
  26. void CFolder::Create(LPCWSTR szName, int nImage, int nOpenImage, SCOPE_TYPES itemType,
  27. FOLDER_TYPES type, BOOL bHasChildren)
  28. {
  29. ASSERT(m_pScopeItem == NULL); // Calling create twice on this item?
  30. // Two-stage construction
  31. m_pScopeItem = new SCOPEDATAITEM;
  32. if(m_pScopeItem == NULL)
  33. {
  34. return;
  35. }
  36. ZeroMemory(m_pScopeItem, sizeof(SCOPEDATAITEM));
  37. // Set folder type
  38. m_type = type;
  39. // Set scope
  40. m_itemType = itemType;
  41. // Add node name
  42. if (szName != NULL)
  43. {
  44. m_pScopeItem->mask = SDI_STR;
  45. m_pScopeItem->displayname = (unsigned short*)(-1);
  46. UINT uiByteLen = (wcslen(szName) + 1) * sizeof(OLECHAR);
  47. LPOLESTR psz = (LPOLESTR)::CoTaskMemAlloc(uiByteLen);
  48. if (psz != NULL)
  49. {
  50. wcscpy(psz, szName);
  51. m_pszName = psz;
  52. }
  53. }
  54. // Add close image
  55. if (nImage != 0)
  56. {
  57. m_pScopeItem->mask |= SDI_IMAGE;
  58. m_pScopeItem->nImage = nImage;
  59. }
  60. // Add open image
  61. if (nOpenImage != 0)
  62. {
  63. m_pScopeItem->mask |= SDI_OPENIMAGE;
  64. m_pScopeItem->nOpenImage = nOpenImage;
  65. }
  66. // Children value is valid
  67. m_pScopeItem->mask |= SDI_CHILDREN;
  68. // Add button to node if the folder has children
  69. if (bHasChildren == TRUE)
  70. {
  71. m_pScopeItem->cChildren = 1;
  72. }
  73. }