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.

889 lines
25 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ExtObj.cpp
  7. //
  8. // Description:
  9. // Implementation of the CExtObject class, which implements the
  10. // extension interfaces required by a Microsoft Windows NT Cluster
  11. // Administrator Extension DLL.
  12. //
  13. // Author:
  14. // <name> (<e-mail name>) Mmmm DD, 2002
  15. //
  16. // Revision History:
  17. //
  18. // Notes:
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #include "stdafx.h"
  22. #include "VSSTaskEx.h"
  23. #include "ExtObj.h"
  24. #include "ResProp.h"
  25. class CStackException : public CException
  26. {
  27. public:
  28. CStackException( BOOL bAutoDelete )
  29. : CException( bAutoDelete )
  30. {
  31. } //*** CStackException()
  32. virtual ~CStackException( void )
  33. {
  34. } //*** ~CStackException()
  35. }; //*** class CStackException
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Global Variables
  38. /////////////////////////////////////////////////////////////////////////////
  39. const WCHAR g_wszResourceTypeNames[] =
  40. CLUS_RESTYPE_NAME_VSSTASK L"\0"
  41. ;
  42. const DWORD g_cchResourceTypeNames = sizeof( g_wszResourceTypeNames ) / sizeof( WCHAR );
  43. static CRuntimeClass * g_rgprtcResPSPages[] = {
  44. RUNTIME_CLASS( CVSSTaskParamsPage ),
  45. NULL
  46. };
  47. static CRuntimeClass ** g_rgpprtcResPSPages[] = {
  48. g_rgprtcResPSPages,
  49. };
  50. static CRuntimeClass ** g_rgpprtcResWizPages[] = {
  51. g_rgprtcResPSPages,
  52. };
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CExtObject
  55. /////////////////////////////////////////////////////////////////////////////
  56. /////////////////////////////////////////////////////////////////////////////
  57. //++
  58. //
  59. // CExtObject::CExtObject
  60. //
  61. // Description:
  62. // Default constructor.
  63. //
  64. // Arguments:
  65. // None.
  66. //
  67. // Return Value:
  68. // None.
  69. //
  70. //--
  71. /////////////////////////////////////////////////////////////////////////////
  72. CExtObject::CExtObject( void )
  73. {
  74. m_piData = NULL;
  75. m_piWizardCallback = NULL;
  76. m_bWizard = FALSE;
  77. m_istrResTypeName = 0;
  78. m_lcid = NULL;
  79. m_hfont = NULL;
  80. m_hicon = NULL;
  81. m_hcluster = NULL;
  82. m_cobj = 0;
  83. m_podObjData = NULL;
  84. } //*** CExtObject::CExtObject()
  85. /////////////////////////////////////////////////////////////////////////////
  86. //++
  87. //
  88. // CExtObject::~CExtObject
  89. //
  90. // Description:
  91. // Destructor.
  92. //
  93. // Arguments:
  94. // None.
  95. //
  96. // Return Value:
  97. // None.
  98. //
  99. //--
  100. /////////////////////////////////////////////////////////////////////////////
  101. CExtObject::~CExtObject( void )
  102. {
  103. // Release the data interface.
  104. if ( PiData() != NULL )
  105. {
  106. PiData()->Release();
  107. m_piData = NULL;
  108. } // if: we have a data interface pointer
  109. // Release the wizard callback interface.
  110. if ( PiWizardCallback() != NULL )
  111. {
  112. PiWizardCallback()->Release();
  113. m_piWizardCallback = NULL;
  114. } // if: we have a wizard callback interface pointer
  115. // Delete the pages.
  116. {
  117. POSITION pos;
  118. pos = Lpg().GetHeadPosition();
  119. while ( pos != NULL )
  120. {
  121. delete Lpg().GetNext(pos);
  122. } // while: more pages in the list
  123. } // Delete the pages
  124. delete m_podObjData;
  125. } //*** CExtObject::~CExtObject()
  126. /////////////////////////////////////////////////////////////////////////////
  127. // ISupportErrorInfo Implementation
  128. /////////////////////////////////////////////////////////////////////////////
  129. //++
  130. //
  131. // CExtObject::InterfaceSupportsErrorInfo (ISupportErrorInfo)
  132. //
  133. // Routine Description:
  134. // Indicates whether an interface suportes the IErrorInfo interface.
  135. // This interface is provided by ATL.
  136. //
  137. // Arguments:
  138. // riid Interface ID.
  139. //
  140. // Return Value:
  141. // S_OK Interface supports IErrorInfo.
  142. // S_FALSE Interface does not support IErrorInfo.
  143. //
  144. //--
  145. /////////////////////////////////////////////////////////////////////////////
  146. STDMETHODIMP CExtObject::InterfaceSupportsErrorInfo(REFIID riid)
  147. {
  148. static const IID * _rgiid[] =
  149. {
  150. &IID_IWEExtendPropertySheet,
  151. &IID_IWEExtendWizard,
  152. };
  153. int _iiid;
  154. for ( _iiid = 0 ; _iiid < sizeof( _rgiid ) / sizeof( _rgiid[ 0 ] ) ; _iiid++ )
  155. {
  156. if ( ::InlineIsEqualGUID( *_rgiid[ _iiid ], riid ) )
  157. {
  158. return S_OK;
  159. } // if: found a matching IID
  160. }
  161. return S_FALSE;
  162. } //*** CExtObject::InterfaceSupportsErrorInfo()
  163. /////////////////////////////////////////////////////////////////////////////
  164. // IWEExtendPropertySheet Implementation
  165. /////////////////////////////////////////////////////////////////////////////
  166. //++
  167. //
  168. // CExtObject::CreatePropertySheetPages (IWEExtendPropertySheet)
  169. //
  170. // Description:
  171. // Create property sheet pages and add them to the sheet.
  172. //
  173. // Arguments:
  174. // piData [IN]
  175. // IUnkown pointer from which to obtain interfaces for obtaining data
  176. // describing the object for which the sheet is being displayed.
  177. //
  178. // piCallback [IN]
  179. // Pointer to an IWCPropertySheetCallback interface for adding pages
  180. // to the sheet.
  181. //
  182. // Return Value:
  183. // NOERROR Pages added successfully.
  184. // E_INVALIDARG Invalid arguments to the function.
  185. // E_OUTOFMEMORY Error allocating memory.
  186. // E_FAIL Error creating a page.
  187. // E_NOTIMPL Not implemented for this type of data.
  188. // _hr Any error codes from HrGetUIInfo() or HrSaveData().
  189. //
  190. //--
  191. /////////////////////////////////////////////////////////////////////////////
  192. STDMETHODIMP CExtObject::CreatePropertySheetPages(
  193. IN IUnknown * piData,
  194. IN IWCPropertySheetCallback * piCallback
  195. )
  196. {
  197. HRESULT _hr = NOERROR;
  198. CStackException _exc( FALSE /*bAutoDelete*/ );
  199. CRuntimeClass ** _pprtc = NULL;
  200. int _irtc;
  201. CBasePropertyPage * _ppage;
  202. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  203. // Validate the parameters.
  204. if ( (piData == NULL) || (piCallback == NULL) )
  205. {
  206. return E_INVALIDARG;
  207. } // if: all interfaces not specified
  208. try
  209. {
  210. // Get info about displaying UI.
  211. _hr = HrGetUIInfo( piData );
  212. if ( _hr != NOERROR )
  213. {
  214. throw &_exc;
  215. } // if: error getting UI info
  216. // Save the data.
  217. _hr = HrSaveData( piData );
  218. if ( _hr != NOERROR )
  219. {
  220. throw &_exc;
  221. } // if: error saving data from host
  222. // Delete any previous pages.
  223. {
  224. POSITION pos;
  225. pos = Lpg().GetHeadPosition();
  226. while ( pos != NULL )
  227. {
  228. delete Lpg().GetNext( pos );
  229. } // while: more pages in the list
  230. Lpg().RemoveAll();
  231. } // Delete any previous pages
  232. // Create property pages.
  233. ASSERT( PodObjData() != NULL );
  234. switch ( PodObjData()->m_cot )
  235. {
  236. case CLUADMEX_OT_RESOURCE:
  237. _pprtc = g_rgpprtcResPSPages[ IstrResTypeName() ];
  238. break;
  239. default:
  240. _hr = E_NOTIMPL;
  241. throw &_exc;
  242. break;
  243. } // switch: object type
  244. // Create each page.
  245. for ( _irtc = 0 ; _pprtc[ _irtc ] != NULL ; _irtc++ )
  246. {
  247. // Create the page.
  248. _ppage = static_cast< CBasePropertyPage * >( _pprtc[ _irtc ]->CreateObject() );
  249. ASSERT( _ppage->IsKindOf( _pprtc[ _irtc ] ) );
  250. // Add it to the list.
  251. Lpg().AddTail( _ppage );
  252. // Initialize the property page.
  253. _hr = _ppage->HrInit( this );
  254. if ( FAILED( _hr ) )
  255. {
  256. throw &_exc;
  257. } // if: error initializing the page
  258. // Create the page.
  259. _hr = _ppage->HrCreatePage();
  260. if ( FAILED( _hr ) )
  261. {
  262. throw &_exc;
  263. } // if: error creating the page
  264. // Add it to the property sheet.
  265. _hr = piCallback->AddPropertySheetPage( reinterpret_cast< LONG * >( _ppage->Hpage() ) );
  266. if ( _hr != NOERROR )
  267. {
  268. throw &_exc;
  269. } // if: error adding the page to the sheet
  270. } // for: each page in the list
  271. } // try
  272. catch ( CMemoryException * _pme )
  273. {
  274. TRACE( _T("CExtObject::CreatePropetySheetPages() - Failed to add property page\n") );
  275. _pme->Delete();
  276. _hr = E_OUTOFMEMORY;
  277. } // catch: anything
  278. catch ( CException * _pe )
  279. {
  280. TRACE( _T("CExtObject::CreatePropetySheetPages() - Failed to add property page\n") );
  281. _pe->Delete();
  282. if ( _hr == NOERROR )
  283. {
  284. _hr = E_FAIL;
  285. } // if: _hr hasn't beeen set yet
  286. } // catch: anything
  287. if ( _hr != NOERROR )
  288. {
  289. piData->Release();
  290. m_piData = NULL;
  291. } // if: error occurred
  292. piCallback->Release();
  293. return _hr;
  294. } //*** CExtObject::CreatePropertySheetPages()
  295. /////////////////////////////////////////////////////////////////////////////
  296. // IWEExtendWizard Implementation
  297. /////////////////////////////////////////////////////////////////////////////
  298. //++
  299. //
  300. // CExtObject::CreateWizardPages (IWEExtendWizard)
  301. //
  302. // Description:
  303. // Create property sheet pages and add them to the wizard.
  304. //
  305. // Arguments:
  306. // piData [IN]
  307. // IUnkown pointer from which to obtain interfaces for obtaining data
  308. // describing the object for which the wizard is being displayed.
  309. //
  310. // piCallback [IN]
  311. // Pointer to an IWCPropertySheetCallback interface for adding pages
  312. // to the sheet.
  313. //
  314. // Return Value:
  315. // NOERROR Pages added successfully.
  316. // E_INVALIDARG Invalid arguments to the function.
  317. // E_OUTOFMEMORY Error allocating memory.
  318. // E_FAIL Error creating a page.
  319. // E_NOTIMPL Not implemented for this type of data.
  320. // _hr Any error codes from HrGetUIInfo() or HrSaveData().
  321. //
  322. //--
  323. /////////////////////////////////////////////////////////////////////////////
  324. STDMETHODIMP CExtObject::CreateWizardPages(
  325. IN IUnknown * piData,
  326. IN IWCWizardCallback * piCallback
  327. )
  328. {
  329. HRESULT _hr = NOERROR;
  330. CStackException _exc( FALSE /*bAutoDelete*/ );
  331. CRuntimeClass ** _pprtc = NULL;
  332. int _irtc;
  333. CBasePropertyPage * _ppage;
  334. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  335. // Validate the parameters.
  336. if ( (piData == NULL) || (piCallback == NULL) )
  337. {
  338. return E_INVALIDARG;
  339. } // if: all interfaces not specified
  340. try
  341. {
  342. // Get info about displaying UI.
  343. _hr = HrGetUIInfo( piData );
  344. if ( _hr != NOERROR )
  345. {
  346. throw &_exc;
  347. } // if: error getting UI info
  348. // Save the data.
  349. _hr = HrSaveData( piData );
  350. if ( _hr != NOERROR )
  351. {
  352. throw &_exc;
  353. } // if: error saving data from host
  354. // Delete any previous pages.
  355. {
  356. POSITION pos;
  357. pos = Lpg().GetHeadPosition();
  358. while ( pos != NULL )
  359. {
  360. delete Lpg().GetNext( pos );
  361. } // while: more pages in the list
  362. Lpg().RemoveAll();
  363. } // Delete any previous pages
  364. m_piWizardCallback = piCallback;
  365. m_bWizard = TRUE;
  366. // Create property pages.
  367. ASSERT( PodObjData() != NULL );
  368. switch ( PodObjData()->m_cot )
  369. {
  370. case CLUADMEX_OT_RESOURCE:
  371. _pprtc = g_rgpprtcResWizPages[ IstrResTypeName() ];
  372. break;
  373. default:
  374. _hr = E_NOTIMPL;
  375. throw &_exc;
  376. break;
  377. } // switch: object type
  378. // Create each page.
  379. for ( _irtc = 0 ; _pprtc[ _irtc ] != NULL ; _irtc++ )
  380. {
  381. // Create the page.
  382. _ppage = static_cast< CBasePropertyPage * >( _pprtc[ _irtc ]->CreateObject() );
  383. ASSERT( _ppage->IsKindOf( _pprtc[ _irtc ] ) );
  384. // Add it to the list.
  385. Lpg().AddTail( _ppage );
  386. // Initialize the property page.
  387. _hr = _ppage->HrInit( this );
  388. if ( FAILED( _hr ) )
  389. {
  390. throw &_exc;
  391. } // if: error initializing the page
  392. // Create the page.
  393. _hr = _ppage->HrCreatePage();
  394. if ( FAILED( _hr ) )
  395. {
  396. throw &_exc;
  397. } // if: error creating the page
  398. // Add it to the property sheet.
  399. _hr = piCallback->AddWizardPage( reinterpret_cast< LONG * >( _ppage->Hpage() ) );
  400. if ( _hr != NOERROR )
  401. {
  402. throw &_exc;
  403. } // if: error adding the page to the sheet
  404. } // for: each page in the list
  405. } // try
  406. catch ( CMemoryException * _pme )
  407. {
  408. TRACE( _T("CExtObject::CreateWizardPages() - Failed to add wizard page\n") );
  409. _pme->Delete();
  410. _hr = E_OUTOFMEMORY;
  411. } // catch: anything
  412. catch ( CException * _pe )
  413. {
  414. TRACE( _T("CExtObject::CreateWizardPages() - Failed to add wizard page\n") );
  415. _pe->Delete();
  416. if ( _hr == NOERROR )
  417. {
  418. _hr = E_FAIL;
  419. } // if: _hr hasn't beeen set yet
  420. } // catch: anything
  421. if ( _hr != NOERROR )
  422. {
  423. piCallback->Release();
  424. if ( m_piWizardCallback == piCallback )
  425. {
  426. m_piWizardCallback = NULL;
  427. } // if: already saved interface pointer
  428. piData->Release();
  429. m_piData = NULL;
  430. } // if: error occurred
  431. return _hr;
  432. } //*** CExtObject::CreateWizardPages()
  433. /////////////////////////////////////////////////////////////////////////////
  434. //++
  435. //
  436. // CExtObject::HrGetUIInfo
  437. //
  438. // Description:
  439. // Get info about displaying UI.
  440. //
  441. // Arguments:
  442. // piData [IN]
  443. // IUnkown pointer from which to obtain interfaces for obtaining data
  444. // describing the object.
  445. //
  446. // Return Value:
  447. // NOERROR
  448. // Data saved successfully.
  449. //
  450. // E_NOTIMPL
  451. // Not implemented for this type of data.
  452. //
  453. // _hr
  454. // Any error codes from IUnknown::QueryInterface(),
  455. // HrGetObjectName(), or HrGetResourceName().
  456. //
  457. //--
  458. /////////////////////////////////////////////////////////////////////////////
  459. HRESULT CExtObject::HrGetUIInfo(IN IUnknown * piData)
  460. {
  461. HRESULT _hr = NOERROR;
  462. ASSERT( piData != NULL );
  463. // Save info about all types of objects.
  464. {
  465. IGetClusterUIInfo * _pi;
  466. _hr = piData->QueryInterface( IID_IGetClusterUIInfo, reinterpret_cast< LPVOID * >( &_pi ) );
  467. if ( _hr != NOERROR )
  468. {
  469. return _hr;
  470. } // if: error querying for interface
  471. m_lcid = _pi->GetLocale();
  472. m_hfont = _pi->GetFont();
  473. m_hicon = _pi->GetIcon();
  474. _pi->Release();
  475. } // Save info about all types of objects
  476. return _hr;
  477. } //*** CExtObject::HrGetUIInfo()
  478. /////////////////////////////////////////////////////////////////////////////
  479. //++
  480. //
  481. // CExtObject::HrSaveData
  482. //
  483. // Routine Description:
  484. // Save data from the object so that it can be used for the life
  485. // of the object.
  486. //
  487. // Arguments:
  488. // piData [IN]
  489. // IUnkown pointer from which to obtain interfaces for obtaining data
  490. // describing the object.
  491. //
  492. // Return Value:
  493. // NOERROR
  494. // Data saved successfully.
  495. //
  496. // E_NOTIMPL
  497. // Not implemented for this type of data.
  498. //
  499. // _hr
  500. // Any error codes from IUnknown::QueryInterface(),
  501. // HrGetObjectName(), or HrGetResourceName().
  502. //
  503. //--
  504. /////////////////////////////////////////////////////////////////////////////
  505. HRESULT CExtObject::HrSaveData(IN IUnknown * piData)
  506. {
  507. HRESULT _hr = NOERROR;
  508. ASSERT( piData != NULL );
  509. if ( piData != m_piData )
  510. {
  511. if ( m_piData != NULL )
  512. {
  513. m_piData->Release();
  514. } // if: interface queried for previously
  515. m_piData = piData;
  516. } // if: different data interface pointer
  517. // Save info about all types of objects.
  518. {
  519. IGetClusterDataInfo * _pi;
  520. _hr = piData->QueryInterface( IID_IGetClusterDataInfo, reinterpret_cast< LPVOID * >( &_pi ) );
  521. if ( _hr != NOERROR )
  522. {
  523. return _hr;
  524. } // if: error querying for interface
  525. m_hcluster = _pi->GetClusterHandle();
  526. m_cobj = _pi->GetObjectCount();
  527. if ( Cobj() != 1 ) // Only have support for one selected object.
  528. {
  529. _hr = E_NOTIMPL;
  530. } // if: too many objects for us to handle
  531. _pi->Release();
  532. if ( _hr != NOERROR )
  533. {
  534. return _hr;
  535. } // if: error occurred before here
  536. } // Save info about all types of objects
  537. // Save info about this object.
  538. _hr = HrGetObjectInfo();
  539. return _hr;
  540. } //*** CExtObject::HrSaveData()
  541. /////////////////////////////////////////////////////////////////////////////
  542. //++
  543. //
  544. // CExtObject::HrGetObjectInfo
  545. //
  546. // Description:
  547. // Get information about the object.
  548. //
  549. // Arguments:
  550. // None.
  551. //
  552. // Return Value:
  553. // NOERROR
  554. // Data saved successfully.
  555. //
  556. // E_OUTOFMEMORY
  557. /// Error allocating memory.
  558. //
  559. // E_NOTIMPL
  560. // Not implemented for this type of data.
  561. //
  562. // _hr
  563. // Any error codes from IUnknown::QueryInterface(),
  564. // HrGetObjectName(), or HrGetResourceTypeName().
  565. //
  566. //--
  567. /////////////////////////////////////////////////////////////////////////////
  568. HRESULT CExtObject::HrGetObjectInfo(void)
  569. {
  570. HRESULT _hr = NOERROR;
  571. IGetClusterObjectInfo * _piGcoi;
  572. CLUADMEX_OBJECT_TYPE _cot;
  573. CStackException _exc( FALSE /*bAutoDelete*/ );
  574. const CString * _pstrResTypeName;
  575. ASSERT( PiData() != NULL );
  576. // Get object info.
  577. {
  578. // Get an IGetClusterObjectInfo interface pointer.
  579. _hr = PiData()->QueryInterface( IID_IGetClusterObjectInfo, reinterpret_cast< LPVOID * >( &_piGcoi ) );
  580. if ( _hr != NOERROR )
  581. {
  582. return _hr;
  583. } // if: error querying for interface
  584. // Read the object data.
  585. try
  586. {
  587. // Delete the previous object data.
  588. delete m_podObjData;
  589. m_podObjData = NULL;
  590. // Get the type of the object.
  591. _cot = _piGcoi->GetObjectType( 0 );
  592. switch ( _cot )
  593. {
  594. case CLUADMEX_OT_RESOURCE:
  595. {
  596. IGetClusterResourceInfo * _pi;
  597. m_podObjData = new CResData;
  598. // Get an IGetClusterResourceInfo interface pointer.
  599. _hr = PiData()->QueryInterface( IID_IGetClusterResourceInfo, reinterpret_cast< LPVOID * >( &_pi ) );
  600. if ( _hr != NOERROR )
  601. {
  602. throw &_exc;
  603. } // if: error querying for interface
  604. PrdResDataRW()->m_hresource = _pi->GetResourceHandle( 0 );
  605. ASSERT( PrdResDataRW()->m_hresource != NULL );
  606. if ( PrdResDataRW()->m_hresource == NULL )
  607. {
  608. _hr = E_INVALIDARG;
  609. } // if invalid resource handle
  610. else
  611. {
  612. _hr = HrGetResourceTypeName( _pi );
  613. } // else: resource handle is valid
  614. _pi->Release();
  615. if ( _hr != NOERROR )
  616. {
  617. throw &_exc;
  618. } // if: error occurred above
  619. _pstrResTypeName = &PrdResDataRW()->m_strResTypeName;
  620. } // if: object is a resource
  621. break;
  622. default:
  623. _hr = E_NOTIMPL;
  624. throw &_exc;
  625. } // switch: object type
  626. PodObjDataRW()->m_cot = _cot;
  627. _hr = HrGetObjectName( _piGcoi );
  628. } // try
  629. catch ( CException * _pe )
  630. {
  631. _pe->Delete();
  632. } // catch: CException
  633. _piGcoi->Release();
  634. if ( _hr != NOERROR )
  635. {
  636. return _hr;
  637. } // if: error occurred above
  638. } // Get object info
  639. // If this is a resource or resource type, see if we know about this type.
  640. if ( ( (_cot == CLUADMEX_OT_RESOURCE)
  641. || (_cot == CLUADMEX_OT_RESOURCETYPE) )
  642. && (_hr == NOERROR) )
  643. {
  644. LPCWSTR _pwszResTypeName;
  645. // Find the resource type name in our list.
  646. // Save the index for use in other arrays.
  647. for ( m_istrResTypeName = 0, _pwszResTypeName = g_wszResourceTypeNames
  648. ; *_pwszResTypeName != L'\0'
  649. ; m_istrResTypeName++, _pwszResTypeName += lstrlenW( _pwszResTypeName ) + 1
  650. )
  651. {
  652. if ( _pstrResTypeName->CompareNoCase( _pwszResTypeName ) == 0 )
  653. {
  654. break;
  655. } // if: found resource type name
  656. } // for: each resource type in the list
  657. if ( *_pwszResTypeName == L'\0' )
  658. {
  659. _hr = E_NOTIMPL;
  660. } // if: resource type name not found
  661. } // See if we know about this resource type
  662. return _hr;
  663. } //*** CExtObject::HrGetObjectInfo()
  664. /////////////////////////////////////////////////////////////////////////////
  665. //++
  666. //
  667. // CExtObject::HrGetObjectName
  668. //
  669. // Description:
  670. // Get the name of the object.
  671. //
  672. // Arguments:
  673. // piData [IN]
  674. // IGetClusterObjectInfo interface pointer for getting the object
  675. // name.
  676. //
  677. // Return Value:
  678. // NOERROR
  679. // Data saved successfully.
  680. //
  681. // E_OUTOFMEMORY
  682. // Error allocating memory.
  683. //
  684. // E_NOTIMPL
  685. // Not implemented for this type of data.
  686. //
  687. // _hr
  688. // Any error codes from IGetClusterObjectInfo::GetObjectInfo().
  689. //
  690. //--
  691. /////////////////////////////////////////////////////////////////////////////
  692. HRESULT CExtObject::HrGetObjectName(IN IGetClusterObjectInfo * pi)
  693. {
  694. HRESULT _hr = NOERROR;
  695. WCHAR * _pwszName = NULL;
  696. LONG _cchName;
  697. ASSERT( pi != NULL );
  698. _hr = pi->GetObjectName( 0, NULL, &_cchName );
  699. if ( _hr != NOERROR )
  700. {
  701. return _hr;
  702. } // if: error getting object name
  703. try
  704. {
  705. _pwszName = new WCHAR[ _cchName ];
  706. _hr = pi->GetObjectName( 0, _pwszName, &_cchName );
  707. if ( _hr != NOERROR )
  708. {
  709. delete [] _pwszName;
  710. _pwszName = NULL;
  711. } // if: error getting object name
  712. PodObjDataRW()->m_strName = _pwszName;
  713. } // try
  714. catch ( CMemoryException * _pme )
  715. {
  716. _pme->Delete();
  717. _hr = E_OUTOFMEMORY;
  718. } // catch: CMemoryException
  719. delete [] _pwszName;
  720. return _hr;
  721. } //*** CExtObject::HrGetObjectName()
  722. /////////////////////////////////////////////////////////////////////////////
  723. //++
  724. //
  725. // CExtObject::HrGetResourceTypeName
  726. //
  727. // Routine Description:
  728. // Get the name of the resource's type.
  729. //
  730. // Arguments:
  731. // piData [IN]
  732. // IGetClusterResourceInfo interface pointer for getting the resource
  733. // type name.
  734. //
  735. // Return Value:
  736. // NOERROR
  737. // Data saved successfully.
  738. //
  739. // E_OUTOFMEMORY
  740. // Error allocating memory.
  741. //
  742. // E_NOTIMPL
  743. // Not implemented for this type of data.
  744. //
  745. // _hr
  746. // Any error codes from IGetClusterResourceInfo
  747. // ::GetResourceTypeName().
  748. //
  749. //--
  750. /////////////////////////////////////////////////////////////////////////////
  751. HRESULT CExtObject::HrGetResourceTypeName(IN IGetClusterResourceInfo * pi)
  752. {
  753. HRESULT _hr = NOERROR;
  754. WCHAR * _pwszName = NULL;
  755. LONG _cchName;
  756. ASSERT( pi != NULL );
  757. _hr = pi->GetResourceTypeName( 0, NULL, &_cchName );
  758. if ( _hr != NOERROR )
  759. {
  760. return _hr;
  761. } // if: error getting resource type name
  762. try
  763. {
  764. _pwszName = new WCHAR[ _cchName ];
  765. _hr = pi->GetResourceTypeName( 0, _pwszName, &_cchName );
  766. if ( _hr != NOERROR )
  767. {
  768. delete [] _pwszName;
  769. _pwszName = NULL;
  770. } // if: error getting resource type name
  771. PrdResDataRW()->m_strResTypeName = _pwszName;
  772. } // try
  773. catch ( CMemoryException * _pme )
  774. {
  775. _pme->Delete();
  776. _hr = E_OUTOFMEMORY;
  777. } // catch: CMemoryException
  778. delete [] _pwszName;
  779. return _hr;
  780. } //*** CExtObject::HrGetResourceTypeName()