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.

162 lines
3.2 KiB

  1. #include "stdafx.h"
  2. #include "DomMigSI.h"
  3. #include "DomMigr.h"
  4. #include "globals.h"
  5. HRESULT
  6. InsertNodeToScopepane(
  7. IConsoleNameSpace * pConsoleNameSpace,
  8. CSnapInItem * pNewNode ,
  9. HSCOPEITEM parentID ,
  10. HSCOPEITEM nextSiblingID
  11. )
  12. {
  13. HRESULT hr = S_OK;
  14. LPSCOPEDATAITEM pDataItem;
  15. hr = pNewNode->GetScopeData(&pDataItem);
  16. if (FAILED(hr))
  17. return hr;
  18. if ( pDataItem->ID )
  19. return hr;
  20. if ( nextSiblingID )
  21. {
  22. pDataItem->relativeID = nextSiblingID;
  23. pDataItem->mask |= SDI_NEXT;
  24. }
  25. else
  26. {
  27. pDataItem->relativeID = parentID;
  28. pDataItem->mask &= ~SDI_NEXT;
  29. pDataItem->mask |= SDI_PARENT;
  30. }
  31. hr = pConsoleNameSpace->InsertItem(pDataItem);
  32. if (FAILED(hr))
  33. return hr;
  34. return hr;
  35. }
  36. HRESULT
  37. InsertNodeToScopepane2(
  38. IConsole * pConsole ,
  39. CSnapInItem * pNewNode ,
  40. HSCOPEITEM parentID ,
  41. HSCOPEITEM nextSiblingID
  42. )
  43. {
  44. HRESULT hr = S_OK;
  45. LPSCOPEDATAITEM pDataItem;
  46. CComQIPtr<IConsoleNameSpace> pNewSpace(pConsole);
  47. hr = pNewNode->GetScopeData(&pDataItem);
  48. if (FAILED(hr))
  49. return hr;
  50. if ( pDataItem->ID )
  51. return hr;
  52. if ( nextSiblingID )
  53. {
  54. pDataItem->relativeID = nextSiblingID;
  55. pDataItem->mask |= SDI_NEXT;
  56. }
  57. else
  58. {
  59. pDataItem->relativeID = parentID;
  60. pDataItem->mask &= ~SDI_NEXT;
  61. pDataItem->mask |= SDI_PARENT;
  62. }
  63. hr = pNewSpace->InsertItem(pDataItem);
  64. if (FAILED(hr))
  65. return hr;
  66. return hr;
  67. }
  68. HRESULT
  69. GetSnapInItemGuid(
  70. CSnapInItem * pItem ,
  71. GUID * pOutGuid
  72. )
  73. {
  74. HRESULT hr = S_OK;
  75. CComPtr<IDataObject> pDataObject;
  76. if ( NULL == pItem )
  77. return E_POINTER;
  78. hr = pItem->GetDataObject( &pDataObject, CCT_RESULT );
  79. if ( FAILED(hr) )
  80. return hr;
  81. STGMEDIUM stgmedium = { TYMED_HGLOBAL, NULL };
  82. FORMATETC formatetc = { CSnapInItem::m_CCF_NODETYPE,
  83. NULL,
  84. DVASPECT_CONTENT,
  85. -1,
  86. TYMED_HGLOBAL
  87. };
  88. //
  89. // Allocate memory to received the GUID.
  90. //
  91. stgmedium.hGlobal = GlobalAlloc( 0, sizeof( GUID ) );
  92. if ( stgmedium.hGlobal == NULL )
  93. return( E_OUTOFMEMORY );
  94. //
  95. // Retrieve the GUID of the paste object.
  96. //
  97. hr = pDataObject->GetDataHere( &formatetc, &stgmedium );
  98. if( FAILED( hr ) )
  99. {
  100. GlobalFree(stgmedium.hGlobal);
  101. return( hr );
  102. }
  103. //
  104. // Make a local copy of the GUID.
  105. //
  106. memcpy( pOutGuid, stgmedium.hGlobal, sizeof( GUID ) );
  107. GlobalFree( stgmedium.hGlobal );
  108. return hr;
  109. }
  110. HRESULT
  111. GetConsoleFromCSnapInObjectRootBase(
  112. CSnapInObjectRootBase* pObj,
  113. IConsole **ppConsole
  114. )
  115. {
  116. HRESULT hr = E_FAIL;
  117. switch (pObj->m_nType)
  118. {
  119. case 1:
  120. {
  121. *ppConsole = ((CDomMigrator*)pObj)->m_spConsole;
  122. (*ppConsole)->AddRef();
  123. hr = S_OK;
  124. }
  125. break;
  126. case 2:
  127. {
  128. *ppConsole = ((CDomMigratorComponent *)pObj)->m_spConsole;
  129. (*ppConsole)->AddRef();
  130. hr = S_OK;
  131. }
  132. break;
  133. }
  134. return hr;
  135. }