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.

735 lines
22 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 2001.
  5. //
  6. // File: dataobj.cpp
  7. //
  8. // Contents: Implementation of data object class
  9. //
  10. // History:
  11. //
  12. //---------------------------------------------------------------------------
  13. #include "stdafx.h"
  14. #include "cookie.h"
  15. #include "snapmgr.h"
  16. #include "DataObj.h"
  17. #include <sceattch.h>
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. ///////////////////////////////////////////////////////////////////////////////
  24. // Snap-in NodeType in both GUID format and string format
  25. UINT CDataObject::m_cfNodeType = RegisterClipboardFormat(CCF_NODETYPE);
  26. UINT CDataObject::m_cfNodeTypeString = RegisterClipboardFormat(CCF_SZNODETYPE);
  27. UINT CDataObject::m_cfNodeID = RegisterClipboardFormat(CCF_NODEID2);
  28. UINT CDataObject::m_cfDisplayName = RegisterClipboardFormat(CCF_DISPLAY_NAME);
  29. UINT CDataObject::m_cfSnapinClassID = RegisterClipboardFormat(CCF_SNAPIN_CLASSID);
  30. UINT CDataObject::m_cfInternal = RegisterClipboardFormat(SNAPIN_INTERNAL);
  31. UINT CDataObject::m_cfSceSvcAttachment = RegisterClipboardFormat(CCF_SCESVC_ATTACHMENT);
  32. UINT CDataObject::m_cfSceSvcAttachmentData = RegisterClipboardFormat(CCF_SCESVC_ATTACHMENT_DATA);
  33. UINT CDataObject::m_cfModeType = RegisterClipboardFormat(CCF_SCE_MODE_TYPE);
  34. UINT CDataObject::m_cfGPTUnknown = RegisterClipboardFormat(CCF_SCE_GPT_UNKNOWN);
  35. UINT CDataObject::m_cfRSOPUnknown = RegisterClipboardFormat(CCF_SCE_RSOP_UNKNOWN);
  36. UINT CDataObject::m_cfMultiSelect = ::RegisterClipboardFormat(CCF_OBJECT_TYPES_IN_MULTI_SELECT);
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CDataObject implementations
  39. //+--------------------------------------------------------------------------
  40. //
  41. // Member: CDataObject::GetDataHere
  42. //
  43. // Synopsis: Fill the hGlobal in [lpmedium] with the requested data
  44. //
  45. // History:
  46. //
  47. //---------------------------------------------------------------------------
  48. STDMETHODIMP
  49. CDataObject::GetDataHere(LPFORMATETC lpFormatetc, // In
  50. LPSTGMEDIUM lpMedium) // In
  51. {
  52. HRESULT hr = DV_E_CLIPFORMAT;
  53. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  54. if (!lpFormatetc)
  55. return E_INVALIDARG;
  56. //
  57. // Based on the CLIPFORMAT, write data to the stream
  58. //
  59. const CLIPFORMAT cf = lpFormatetc->cfFormat;
  60. if (cf == m_cfNodeType)
  61. hr = CreateNodeTypeData(lpMedium);
  62. else if (cf == m_cfNodeTypeString)
  63. hr = CreateNodeTypeStringData(lpMedium);
  64. else if (cf == m_cfDisplayName)
  65. hr = CreateDisplayName(lpMedium);
  66. else if (cf == m_cfSnapinClassID)
  67. hr = CreateSnapinClassID(lpMedium);
  68. else if (cf == m_cfInternal)
  69. hr = CreateInternal(lpMedium);
  70. else if (cf == m_cfSceSvcAttachment)
  71. hr = CreateSvcAttachment(lpMedium);
  72. else if (cf == m_cfSceSvcAttachmentData)
  73. hr = CreateSvcAttachmentData(lpMedium);
  74. else if (cf == m_cfModeType)
  75. hr = CreateModeType(lpMedium);
  76. else if (cf == m_cfGPTUnknown)
  77. hr = CreateGPTUnknown(lpMedium);
  78. else if (cf == m_cfRSOPUnknown)
  79. hr = CreateRSOPUnknown(lpMedium);
  80. return hr;
  81. }
  82. //+--------------------------------------------------------------------------
  83. //
  84. // Member: CDataObject::GetData
  85. //
  86. // Synopsis: Support for mutli select is added. First return the mutli
  87. // select GUID information if that is what we are being called for.
  88. // The else if copies the actual mutli-select information.
  89. //
  90. // The function will only copy the mutli select information if
  91. // the FORMATEETC.cfFormat == CDataObject::m_cfInternal and
  92. // FORMATETC.tymed == TYMED_HGLOBAL.
  93. //
  94. // History: 1-14-1999 - a-mthoge
  95. //
  96. //---------------------------------------------------------------------------
  97. STDMETHODIMP
  98. CDataObject::GetData(LPFORMATETC lpFormatetcIn,
  99. LPSTGMEDIUM lpMedium)
  100. {
  101. HRESULT hRet = S_OK;
  102. if (NULL == lpFormatetcIn ||
  103. NULL == lpMedium)
  104. {
  105. return E_POINTER;
  106. }
  107. if(lpFormatetcIn->cfFormat == m_cfMultiSelect &&
  108. lpFormatetcIn->tymed == TYMED_HGLOBAL &&
  109. m_nInternalArray )
  110. {
  111. //
  112. // Need to create a SSMCObjectTypes structure and return this
  113. // to MMC for mutli select.
  114. //
  115. // we only support result items created by SCE.
  116. //
  117. lpMedium->hGlobal = GlobalAlloc(GMEM_SHARE, sizeof(DWORD) + sizeof(GUID) );
  118. if(!lpMedium->hGlobal)
  119. return E_FAIL;
  120. //
  121. // Set count and GUID to 1.
  122. //
  123. SMMCObjectTypes *pTypes = (SMMCObjectTypes *)GlobalLock(lpMedium->hGlobal);
  124. pTypes->count = 1;
  125. memcpy( &(pTypes->guid), &m_internal.m_clsid, sizeof(GUID));
  126. GlobalUnlock(lpMedium->hGlobal);
  127. return S_OK;
  128. }
  129. else if(lpFormatetcIn->cfFormat == m_cfInternal &&
  130. lpFormatetcIn->tymed == TYMED_HGLOBAL &&
  131. m_nInternalArray )
  132. {
  133. //
  134. // Copy the contents of the mutli select to STGMEDIUM
  135. //
  136. lpMedium->hGlobal = GlobalAlloc( GMEM_SHARE, sizeof(INTERNAL) * (m_nInternalArray + 1));
  137. if(!lpMedium->hGlobal)
  138. return E_FAIL;
  139. //
  140. // The first element in the array is set to
  141. // MMC_MUTLI_SELECT_COOKIE and the type is set the count of items after the
  142. // first structure.
  143. //
  144. INTERNAL *pInternal = (INTERNAL *)GlobalLock( lpMedium->hGlobal );
  145. pInternal->m_cookie = (MMC_COOKIE)MMC_MULTI_SELECT_COOKIE;
  146. pInternal->m_type = (DATA_OBJECT_TYPES)m_nInternalArray;
  147. //
  148. // Copy the rest of the INTERNAL structures to this array.
  149. //
  150. pInternal++;
  151. memcpy(pInternal, m_pInternalArray, sizeof(INTERNAL) * m_nInternalArray);
  152. }
  153. else if (lpFormatetcIn->cfFormat == m_cfNodeID &&
  154. lpFormatetcIn->tymed == TYMED_HGLOBAL )
  155. {
  156. return CreateNodeId(lpMedium);
  157. }
  158. return hRet;
  159. }
  160. //+--------------------------------------------------------------------------
  161. //
  162. // Member: CDataObject::EnumFormatEtc
  163. //
  164. // Synopsis: Not implemented
  165. //
  166. // History:
  167. //
  168. //---------------------------------------------------------------------------
  169. STDMETHODIMP
  170. CDataObject::EnumFormatEtc(DWORD dwDirection,
  171. LPENUMFORMATETC*
  172. ppEnumFormatEtc)
  173. {
  174. return E_NOTIMPL;
  175. }
  176. /////////////////////////////////////////////////////////////////////////////
  177. // CDataObject creation members
  178. //+--------------------------------------------------------------------------
  179. //
  180. // Member: CDataObject::Create
  181. //
  182. // Synopsis: Fill the hGlobal in [lpmedium] with the data in pBuffer
  183. //
  184. // Arguments: [pBuffer] - [in] the data to be written
  185. // [len] - [in] the length of that data
  186. // [lpMedium] - [in,out] where to store the data
  187. // History:
  188. //
  189. //---------------------------------------------------------------------------
  190. HRESULT
  191. CDataObject::Create(const void* pBuffer,
  192. int len,
  193. LPSTGMEDIUM lpMedium)
  194. {
  195. HRESULT hr = DV_E_TYMED;
  196. //
  197. // Do some simple validation
  198. //
  199. if (pBuffer == NULL || lpMedium == NULL)
  200. return E_POINTER;
  201. //
  202. // Make sure the type medium is HGLOBAL
  203. //
  204. if (lpMedium->tymed == TYMED_HGLOBAL)
  205. {
  206. //
  207. // Create the stream on the hGlobal passed in
  208. //
  209. LPSTREAM lpStream;
  210. hr = CreateStreamOnHGlobal(lpMedium->hGlobal, FALSE, &lpStream);
  211. if (SUCCEEDED(hr))
  212. {
  213. //
  214. // Write to the stream the number of bytes
  215. //
  216. ULONG written;
  217. hr = lpStream->Write(pBuffer, len, &written);
  218. //
  219. // Because we told CreateStreamOnHGlobal with 'FALSE',
  220. // only the stream is released here.
  221. // Note - the caller (i.e. snap-in, object) will free the HGLOBAL
  222. // at the correct time. This is according to the IDataObject specification.
  223. //
  224. lpStream->Release();
  225. }
  226. }
  227. return hr;
  228. }
  229. //+--------------------------------------------------------------------------
  230. //
  231. // Member: CDataObject::CreateNodeTypeData
  232. //
  233. // Synopsis: Fill the hGlobal in [lpMedium] with our node type
  234. //
  235. // History:
  236. //
  237. //---------------------------------------------------------------------------
  238. HRESULT
  239. CDataObject::CreateNodeTypeData(LPSTGMEDIUM lpMedium)
  240. {
  241. const GUID *pNodeType;
  242. //
  243. // Create the node type object in GUID format
  244. //
  245. switch (m_internal.m_foldertype)
  246. {
  247. case LOCALPOL:
  248. pNodeType = &cNodetypeSceTemplate;
  249. break;
  250. case PROFILE:
  251. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) ||
  252. ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  253. {
  254. pNodeType = &cNodetypeSceTemplate;
  255. }
  256. else
  257. {
  258. // other areas aren't extensible on this node
  259. // return our generic node type
  260. pNodeType = &cSCENodeType;
  261. }
  262. break;
  263. case AREA_SERVICE_ANALYSIS:
  264. pNodeType = &cNodetypeSceAnalysisServices;
  265. break;
  266. case AREA_SERVICE:
  267. pNodeType = &cNodetypeSceTemplateServices;
  268. break;
  269. default:
  270. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) )
  271. pNodeType = &cNodeType;
  272. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  273. pNodeType = &cRSOPNodeType;
  274. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_SAVSnapin) )
  275. pNodeType = &cSAVNodeType;
  276. else
  277. pNodeType = &cSCENodeType;
  278. break;
  279. }
  280. return Create(reinterpret_cast<const void*>(pNodeType), sizeof(GUID), lpMedium);
  281. }
  282. //+--------------------------------------------------------------------------
  283. //
  284. // Member: CDataObject::CreateNodeTypeStringData
  285. //
  286. // Synopsis: Fill the hGlobal in [lpMedium] with the string representation
  287. // of our node type
  288. //
  289. // History:
  290. //
  291. //---------------------------------------------------------------------------
  292. HRESULT CDataObject::CreateNodeTypeStringData(LPSTGMEDIUM lpMedium)
  293. {
  294. //
  295. // Create the node type object in GUID string format
  296. //
  297. LPCTSTR pszNodeType;
  298. switch (m_internal.m_foldertype)
  299. {
  300. case AREA_SERVICE_ANALYSIS:
  301. pszNodeType = lstruuidNodetypeSceAnalysisServices;
  302. break;
  303. case AREA_SERVICE:
  304. pszNodeType = lstruuidNodetypeSceTemplateServices;
  305. break;
  306. case LOCALPOL:
  307. pszNodeType = lstruuidNodetypeSceTemplate;
  308. break;
  309. case PROFILE:
  310. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) )
  311. pszNodeType = lstruuidNodetypeSceTemplate;
  312. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  313. pszNodeType = lstruuidNodetypeSceTemplate;
  314. else
  315. {
  316. // other snapin types do not allow extensions on this level
  317. // return our generic node type
  318. pszNodeType = cszSCENodeType;
  319. }
  320. break;
  321. default:
  322. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) )
  323. pszNodeType = cszNodeType;
  324. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  325. pszNodeType = cszRSOPNodeType;
  326. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_SAVSnapin) )
  327. pszNodeType = cszSAVNodeType;
  328. else
  329. pszNodeType = cszSCENodeType;
  330. break;
  331. }
  332. return Create(pszNodeType, ((wcslen(pszNodeType)+1) * sizeof(WCHAR)), lpMedium);
  333. }
  334. //+--------------------------------------------------------------------------
  335. //
  336. // Member: CDataObject::CreateNodeID
  337. //
  338. // Synopsis: Create an hGlobal in [lpMedium] with our node ID
  339. //
  340. // History:
  341. //
  342. //---------------------------------------------------------------------------
  343. HRESULT
  344. CDataObject::CreateNodeId(LPSTGMEDIUM lpMedium)
  345. {
  346. SNodeID2 *nodeID = NULL;
  347. BYTE *id = NULL;
  348. DWORD dwIDSize = 0;
  349. DWORD dwIDNameSize = 0;
  350. LPTSTR szNodeName = NULL;
  351. CFolder *pFolder = NULL;
  352. LPTSTR szMedium = NULL;
  353. //
  354. // Create the node type object in GUID format
  355. //
  356. switch (m_internal.m_foldertype)
  357. {
  358. case LOCATIONS:
  359. case PROFILE:
  360. case REG_OBJECTS:
  361. case FILE_OBJECTS:
  362. //
  363. // There can be many nodes of these types and they will be
  364. // locked to the system so just use the display name
  365. //
  366. if (m_internal.m_cookie)
  367. {
  368. pFolder = reinterpret_cast<CFolder*>(m_internal.m_cookie);
  369. szNodeName = pFolder->GetName();
  370. dwIDNameSize = (lstrlen(szNodeName)+1)*sizeof(TCHAR);
  371. dwIDSize = sizeof(SNodeID2)+dwIDNameSize;
  372. lpMedium->hGlobal = GlobalAlloc(GMEM_SHARE,dwIDSize);
  373. if(!lpMedium->hGlobal)
  374. return STG_E_MEDIUMFULL;
  375. nodeID = (SNodeID2 *)GlobalLock(lpMedium->hGlobal);
  376. nodeID->dwFlags = 0;
  377. nodeID->cBytes = dwIDNameSize;
  378. memcpy(nodeID->id,szNodeName,dwIDNameSize);
  379. }
  380. else
  381. return E_FAIL;
  382. break;
  383. default:
  384. //
  385. // Everything else is unique: there's one and only one node
  386. // of the type per snapin.
  387. //
  388. dwIDSize = sizeof(FOLDER_TYPES)+sizeof(SNodeID2);
  389. lpMedium->hGlobal = GlobalAlloc(GMEM_SHARE,dwIDSize);
  390. if(!lpMedium->hGlobal)
  391. return STG_E_MEDIUMFULL;
  392. nodeID = (SNodeID2 *)GlobalLock(lpMedium->hGlobal);
  393. nodeID->dwFlags = 0;
  394. nodeID->cBytes = sizeof(FOLDER_TYPES);
  395. memcpy(nodeID->id,&(m_internal.m_foldertype),sizeof(FOLDER_TYPES));
  396. GlobalUnlock(lpMedium->hGlobal);
  397. break;
  398. }
  399. return S_OK;
  400. }
  401. //+--------------------------------------------------------------------------
  402. //
  403. // Member: CDataObject::CreateNodeTypeData
  404. //
  405. // Synopsis: Fill the hGlobal in [lpMedium] with SCE's display name,
  406. // which will differ depending on where it's being viewed from
  407. // as reported by the mode bits
  408. //
  409. // History:
  410. //
  411. //---------------------------------------------------------------------------
  412. HRESULT CDataObject::CreateDisplayName(LPSTGMEDIUM lpMedium)
  413. {
  414. //
  415. // This is the display named used in the scope pane and snap-in manager
  416. //
  417. //
  418. // Load the name from resource
  419. // Note - if this is not provided, the console will used the snap-in name
  420. //
  421. CString szDispName;
  422. if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_SAVSnapin) )
  423. szDispName.LoadString(IDS_ANALYSIS_VIEWER_NAME);
  424. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_SCESnapin) )
  425. szDispName.LoadString(IDS_TEMPLATE_EDITOR_NAME);
  426. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_LSSnapin) )
  427. szDispName.LoadString(IDS_LOCAL_SECURITY_NAME);
  428. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_Snapin) )
  429. szDispName.LoadString(IDS_EXTENSION_NAME);
  430. else if ( ::IsEqualGUID(m_internal.m_clsid, CLSID_RSOPSnapin) )
  431. szDispName.LoadString(IDS_EXTENSION_NAME);
  432. else
  433. szDispName.LoadString(IDS_NODENAME);
  434. /* // can't depend on m_ModeBits because it's not set yet
  435. if (m_ModeBits & MB_ANALYSIS_VIEWER) {
  436. szDispName.LoadString(IDS_ANALYSIS_VIEWER_NAME);
  437. } else if (m_ModeBits & MB_TEMPLATE_EDITOR) {
  438. szDispName.LoadString(IDS_TEMPLATE_EDITOR_NAME);
  439. } else if ( (m_ModeBits & MB_NO_NATIVE_NODES) ||
  440. (m_ModeBits & MB_SINGLE_TEMPLATE_ONLY) ) {
  441. szDispName.LoadString(IDS_EXTENSION_NAME);
  442. } else {
  443. szDispName.LoadString(IDS_NODENAME);
  444. }
  445. */
  446. return Create(szDispName, ((szDispName.GetLength()+1) * sizeof(WCHAR)), lpMedium);
  447. }
  448. //+--------------------------------------------------------------------------
  449. //
  450. // Member: CDataObject::CreateSnapinClassID
  451. //
  452. // Synopsis: Fill the hGlobal in [lpMedium] with SCE's class ID
  453. //
  454. // History:
  455. //
  456. //---------------------------------------------------------------------------
  457. HRESULT CDataObject::CreateSnapinClassID(LPSTGMEDIUM lpMedium)
  458. {
  459. //
  460. // Create the snapin classid in CLSID format
  461. //
  462. return Create(reinterpret_cast<const void*>(&m_internal.m_clsid), sizeof(CLSID), lpMedium);
  463. }
  464. //+--------------------------------------------------------------------------
  465. //
  466. // Member: CDataObject::CreateInternal
  467. //
  468. // Synopsis: Fill the hGlobal in [lpMedium] with SCE's internal data type
  469. //
  470. // History:
  471. //
  472. //---------------------------------------------------------------------------
  473. HRESULT CDataObject::CreateInternal(LPSTGMEDIUM lpMedium)
  474. {
  475. return Create(&m_internal, sizeof(INTERNAL), lpMedium);
  476. }
  477. //+--------------------------------------------------------------------------
  478. //
  479. // Member: CDataObject::AddInternal
  480. //
  481. // Synopsis: Adds an INTERNAL object to the array of internal objects.
  482. //
  483. // History: 1-14-1999 a-mthoge
  484. //
  485. //---------------------------------------------------------------------------
  486. void CDataObject::AddInternal( MMC_COOKIE cookie, DATA_OBJECT_TYPES type)
  487. {
  488. //
  489. // Allocate memory for one more internal array.
  490. INTERNAL *hNew = (INTERNAL *)LocalAlloc( 0, sizeof(INTERNAL) * (m_nInternalArray + 1) );
  491. if(!hNew)
  492. return;
  493. m_nInternalArray++;
  494. //
  495. // Copy other internal array information.
  496. //
  497. if( m_pInternalArray )
  498. {
  499. memcpy(hNew, m_pInternalArray, sizeof(INTERNAL) * (m_nInternalArray - 1) );
  500. LocalFree( m_pInternalArray );
  501. }
  502. //
  503. // Set the new internal array members.
  504. //
  505. hNew[ m_nInternalArray - 1].m_cookie = cookie;
  506. hNew[ m_nInternalArray - 1].m_type = type;
  507. //
  508. // Set the CObjectData internal array pointer.
  509. //
  510. m_pInternalArray = hNew;
  511. }
  512. //+--------------------------------------------------------------------------
  513. //
  514. // Member: CDataObject::CreateSvcAttachment
  515. //
  516. // Synopsis: Fill the hGlobal in [lpMedium] with the name of the inf
  517. // template a service attachment should modify or with an empty
  518. // string for the inf-templateless analysis section
  519. //
  520. // History:
  521. //
  522. //---------------------------------------------------------------------------
  523. HRESULT CDataObject::CreateSvcAttachment(LPSTGMEDIUM lpMedium)
  524. {
  525. LPCTSTR sz = 0;
  526. if ((AREA_SERVICE == m_internal.m_foldertype) ||
  527. (AREA_SERVICE_ANALYSIS == m_internal.m_foldertype))
  528. {
  529. CFolder *pFolder = reinterpret_cast<CFolder *>(m_internal.m_cookie);
  530. if (pFolder)
  531. {
  532. sz = pFolder->GetInfFile();
  533. if (sz)
  534. return Create(sz,(lstrlen(sz)+1)*sizeof(TCHAR),lpMedium);
  535. else
  536. return E_FAIL;
  537. }
  538. else
  539. return E_FAIL;
  540. }
  541. //
  542. // This shouldn't be asked for except in the SERVICE areas
  543. //
  544. return E_UNEXPECTED;
  545. }
  546. //+--------------------------------------------------------------------------
  547. //
  548. // Member: CDataObject::CreateSvcAttachmentData
  549. //
  550. // Synopsis: Fill the hGlobal in [lpMedium] with a pointer to the
  551. // ISceSvcAttachmentData interface that an attachment should use
  552. // to communicate with SCE
  553. //
  554. // History:
  555. //
  556. //---------------------------------------------------------------------------
  557. HRESULT CDataObject::CreateSvcAttachmentData(LPSTGMEDIUM lpMedium)
  558. {
  559. if ((AREA_SERVICE == m_internal.m_foldertype) ||
  560. (AREA_SERVICE_ANALYSIS == m_internal.m_foldertype))
  561. {
  562. return Create(&m_pSceSvcAttachmentData,sizeof(m_pSceSvcAttachmentData),lpMedium);
  563. }
  564. //
  565. // This shouldn't be asked for except in the SERVICE areas
  566. //
  567. return E_UNEXPECTED;
  568. }
  569. //+--------------------------------------------------------------------------
  570. //
  571. // Member: CDataObject::CreateModeType
  572. //
  573. // Synopsis: Fill the hGlobal in [lpMedium] with the Mode that SCE was
  574. // started in
  575. //
  576. // History:
  577. //
  578. //---------------------------------------------------------------------------
  579. HRESULT CDataObject::CreateModeType(LPSTGMEDIUM lpMedium)
  580. {
  581. DWORD mode = m_Mode;
  582. if (mode == SCE_MODE_DOMAIN_COMPUTER_ERROR)
  583. mode = SCE_MODE_DOMAIN_COMPUTER;
  584. return Create(&mode,sizeof(DWORD),lpMedium);
  585. }
  586. //+--------------------------------------------------------------------------
  587. //
  588. // Member: CDataObject::CreateGPTUnknown
  589. //
  590. // Synopsis: Fill the hGlobal in [lpMedium] with a pointer to GPT's
  591. // IUnknown interface. The object requesting this will be
  592. // responsible for Releasing the interface
  593. //
  594. // History:
  595. //
  596. //---------------------------------------------------------------------------
  597. HRESULT CDataObject::CreateGPTUnknown(LPSTGMEDIUM lpMedium)
  598. {
  599. LPUNKNOWN pUnk = 0;
  600. if (!m_pGPTInfo)
  601. {
  602. //
  603. // If we don't have a pointer to a GPT interface then we must not
  604. // be in a mode where we're extending GPT and we can't provide a
  605. // pointer to its IUnknown
  606. //
  607. return E_UNEXPECTED;
  608. }
  609. HRESULT hr = m_pGPTInfo->QueryInterface(IID_IUnknown,
  610. reinterpret_cast<void **>(&pUnk));
  611. if (SUCCEEDED(hr))
  612. return Create(&pUnk,sizeof(pUnk),lpMedium);
  613. else
  614. return hr;
  615. }
  616. //+--------------------------------------------------------------------------
  617. //
  618. // Member: CDataObject::CreateRSOPUnknown
  619. //
  620. // Synopsis: Fill the hGlobal in [lpMedium] with a pointer to RSOP's
  621. // IUnknown interface. The object requesting this will be
  622. // responsible for Releasing the interface
  623. //
  624. // History:
  625. //
  626. //---------------------------------------------------------------------------
  627. HRESULT CDataObject::CreateRSOPUnknown(LPSTGMEDIUM lpMedium)
  628. {
  629. HRESULT hr = E_FAIL;
  630. LPUNKNOWN pUnk = NULL;
  631. if (!m_pRSOPInfo)
  632. {
  633. //
  634. // If we don't have a pointer to a RSOP interface then we must not
  635. // be in a mode where we're extending RSOP and we can't provide a
  636. // pointer to its IUnknown
  637. //
  638. return E_UNEXPECTED;
  639. }
  640. hr = m_pRSOPInfo->QueryInterface(IID_IUnknown,
  641. reinterpret_cast<void **>(&pUnk));
  642. if (SUCCEEDED(hr))
  643. return Create(&pUnk,sizeof(pUnk),lpMedium);
  644. else
  645. return hr;
  646. }