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.

894 lines
18 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ManagedDevice.cpp
  7. //
  8. // Description:
  9. // CManagedDevice implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-FEB-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "pch.h"
  16. #include "ManagedDevice.h"
  17. DEFINE_THISCLASS("CManagedDevice")
  18. // ************************************************************************
  19. //
  20. // Constructor / Destructor
  21. //
  22. // ************************************************************************
  23. //////////////////////////////////////////////////////////////////////////////
  24. //++
  25. //
  26. // HRESULT
  27. // CManagedDevice::S_HrCreateInstance(
  28. // IUnknown ** ppunkOut
  29. // )
  30. //
  31. //--
  32. //////////////////////////////////////////////////////////////////////////////
  33. HRESULT
  34. CManagedDevice::S_HrCreateInstance(
  35. IUnknown ** ppunkOut
  36. )
  37. {
  38. TraceFunc( "" );
  39. Assert( ppunkOut != NULL );
  40. HRESULT hr;
  41. CManagedDevice * pmd = new CManagedDevice;
  42. if ( pmd != NULL )
  43. {
  44. hr = THR( pmd->Init( ) );
  45. if ( SUCCEEDED( hr ) )
  46. {
  47. hr = THR( pmd->TypeSafeQI( IUnknown, ppunkOut ) );
  48. }
  49. pmd->Release( );
  50. }
  51. else
  52. {
  53. hr = E_OUTOFMEMORY;
  54. }
  55. HRETURN( hr );
  56. } //*** CManagedDevice::S_HrCreateInstance( )
  57. //////////////////////////////////////////////////////////////////////////////
  58. //++
  59. //
  60. // CManagedDevice::CManagedDevice( void )
  61. //
  62. //--
  63. //////////////////////////////////////////////////////////////////////////////
  64. CManagedDevice::CManagedDevice( void )
  65. {
  66. TraceFunc( "" );
  67. InterlockedIncrement( &g_cObjects );
  68. TraceFuncExit();
  69. } //*** CManagedDevice::CManagedDevice( )
  70. //////////////////////////////////////////////////////////////////////////////
  71. //++
  72. //
  73. // STDMETHODIMP
  74. // CManagedDevice::Init( void )
  75. //
  76. //--
  77. //////////////////////////////////////////////////////////////////////////////
  78. STDMETHODIMP
  79. CManagedDevice::Init( void )
  80. {
  81. TraceFunc( "" );
  82. HRESULT hr = S_OK;
  83. // IUnknown stuff
  84. Assert( m_cRef == 0 );
  85. AddRef( ); // Add one count
  86. // IClusCfgManagedResourceInfo
  87. Assert( m_bstrUID == NULL );
  88. Assert( m_bstrName == NULL );
  89. Assert( m_fHasNameChanged == FALSE );
  90. Assert( m_bstrType == NULL );
  91. Assert( m_fIsManaged == FALSE );
  92. Assert( m_fIsQuorumDevice == FALSE );
  93. Assert( m_fIsQuorumCapable == FALSE );
  94. Assert( m_fIsQuorumJoinable == FALSE );
  95. Assert( m_dlmDriveLetterMapping.dluDrives[ 0 ] = dluUNUSED );
  96. // IExtendObjectManager
  97. HRETURN( hr );
  98. } //*** CManagedDevice::Init( )
  99. //////////////////////////////////////////////////////////////////////////////
  100. //++
  101. //
  102. // CManagedDevice::~CManagedDevice( void )
  103. //
  104. //--
  105. //////////////////////////////////////////////////////////////////////////////
  106. CManagedDevice::~CManagedDevice( void )
  107. {
  108. TraceFunc( "" );
  109. if ( m_bstrUID != NULL )
  110. {
  111. TraceSysFreeString( m_bstrUID );
  112. }
  113. if ( m_bstrName != NULL )
  114. {
  115. TraceSysFreeString( m_bstrName );
  116. }
  117. if ( m_bstrType != NULL )
  118. {
  119. TraceSysFreeString( m_bstrType );
  120. }
  121. InterlockedDecrement( &g_cObjects );
  122. TraceFuncExit();
  123. } //*** CManagedDevice::~CManagedDevice( )
  124. // ************************************************************************
  125. //
  126. // IUnknown
  127. //
  128. // ************************************************************************
  129. //////////////////////////////////////////////////////////////////////////////
  130. //++
  131. //
  132. // STDMETHODIMP
  133. // CManagedDevice::QueryInterface(
  134. // REFIID riidIn,
  135. // LPVOID * ppvOut
  136. // )
  137. //
  138. //--
  139. //////////////////////////////////////////////////////////////////////////////
  140. STDMETHODIMP
  141. CManagedDevice::QueryInterface(
  142. REFIID riidIn,
  143. LPVOID * ppvOut
  144. )
  145. {
  146. TraceQIFunc( riidIn, ppvOut );
  147. HRESULT hr = E_NOINTERFACE;
  148. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  149. {
  150. *ppvOut = static_cast< IClusCfgManagedResourceInfo * >( this );
  151. hr = S_OK;
  152. } // if: IUnknown
  153. else if ( IsEqualIID( riidIn, IID_IClusCfgManagedResourceInfo ) )
  154. {
  155. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgManagedResourceInfo, this, 0 );
  156. hr = S_OK;
  157. } // else if: IClusCfgManagedResourceInfo
  158. else if ( IsEqualIID( riidIn, IID_IGatherData ) )
  159. {
  160. *ppvOut = TraceInterface( __THISCLASS__, IGatherData, this, 0 );
  161. hr = S_OK;
  162. } // else if: IGatherData
  163. else if ( IsEqualIID( riidIn, IID_IExtendObjectManager ) )
  164. {
  165. *ppvOut = TraceInterface( __THISCLASS__, IExtendObjectManager, this, 0 );
  166. hr = S_OK;
  167. } // else if: IGatherData
  168. if ( SUCCEEDED( hr ) )
  169. {
  170. ((IUnknown*) *ppvOut)->AddRef( );
  171. } // if: success
  172. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  173. } //*** CManagedDevice::QueryInterface( )
  174. //////////////////////////////////////////////////////////////////////////////
  175. //++
  176. //
  177. // STDMETHODIMP_( ULONG )
  178. // CManagedDevice::AddRef( void )
  179. //
  180. //--
  181. //////////////////////////////////////////////////////////////////////////////
  182. STDMETHODIMP_( ULONG )
  183. CManagedDevice::AddRef( void )
  184. {
  185. TraceFunc( "[IUnknown]" );
  186. InterlockedIncrement( &m_cRef );
  187. RETURN( m_cRef );
  188. } //*** CManagedDevice::AddRef( )
  189. //////////////////////////////////////////////////////////////////////////////
  190. //++
  191. //
  192. // STDMETHODIMP_( ULONG )
  193. // CManagedDevice::Release( void )
  194. //
  195. //--
  196. //////////////////////////////////////////////////////////////////////////////
  197. STDMETHODIMP_( ULONG )
  198. CManagedDevice::Release( void )
  199. {
  200. TraceFunc( "[IUnknown]" );
  201. InterlockedDecrement( &m_cRef );
  202. if ( m_cRef )
  203. RETURN( m_cRef );
  204. TraceDo( delete this );
  205. RETURN(0);
  206. } //*** CManagedDevice::Release( )
  207. // ************************************************************************
  208. //
  209. // IClusCfgManagedResourceInfo
  210. //
  211. // ************************************************************************
  212. ///////////////////////////////////////////////////////////////////////////////
  213. //++
  214. //
  215. // STDMETHODIMP
  216. // CManagedDevice::GetUID(
  217. // BSTR * pbstrUIDOut
  218. // )
  219. //
  220. //--
  221. ///////////////////////////////////////////////////////////////////////////////
  222. STDMETHODIMP
  223. CManagedDevice::GetUID(
  224. BSTR * pbstrUIDOut
  225. )
  226. {
  227. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  228. HRESULT hr = S_OK;
  229. if ( pbstrUIDOut == NULL )
  230. goto InvalidPointer;
  231. if ( m_bstrUID == NULL )
  232. goto UnexpectedError;
  233. *pbstrUIDOut = SysAllocString( m_bstrUID );
  234. if ( *pbstrUIDOut == NULL )
  235. goto OutOfMemory;
  236. Cleanup:
  237. HRETURN( hr );
  238. InvalidPointer:
  239. hr = THR( E_POINTER );
  240. goto Cleanup;
  241. UnexpectedError:
  242. hr = THR( E_UNEXPECTED );
  243. goto Cleanup;
  244. OutOfMemory:
  245. hr = E_OUTOFMEMORY;
  246. goto Cleanup;
  247. } //*** CManagedDevice::GetUID( )
  248. ///////////////////////////////////////////////////////////////////////////////
  249. //++
  250. //
  251. // STDMETHODIMP
  252. // CManagedDevice::GetName(
  253. // BSTR * pbstrNameOut
  254. // )
  255. //
  256. //--
  257. ///////////////////////////////////////////////////////////////////////////////
  258. STDMETHODIMP
  259. CManagedDevice::GetName(
  260. BSTR * pbstrNameOut
  261. )
  262. {
  263. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  264. HRESULT hr = S_OK;
  265. if ( pbstrNameOut == NULL )
  266. goto InvalidPointer;
  267. if ( m_bstrName == NULL )
  268. goto UnexpectedError;
  269. *pbstrNameOut = SysAllocString( m_bstrName );
  270. if ( *pbstrNameOut == NULL )
  271. goto OutOfMemory;
  272. Cleanup:
  273. HRETURN( hr );
  274. InvalidPointer:
  275. hr = THR( E_POINTER );
  276. goto Cleanup;
  277. UnexpectedError:
  278. hr = THR( E_UNEXPECTED );
  279. goto Cleanup;
  280. OutOfMemory:
  281. hr = E_OUTOFMEMORY;
  282. goto Cleanup;
  283. } //*** CManagedDevice::GetName( )
  284. ///////////////////////////////////////////////////////////////////////////////
  285. //++
  286. //
  287. // STDMETHODIMP
  288. // CManagedDevice::SetName(
  289. // BSTR bstrNameIn
  290. // )
  291. //
  292. //--
  293. ///////////////////////////////////////////////////////////////////////////////
  294. STDMETHODIMP
  295. CManagedDevice::SetName(
  296. LPCWSTR pcszNameIn
  297. )
  298. {
  299. TraceFunc1( "[IClusCfgManagedResourceInfo] pcszNameIn = '%ws'", ( pcszNameIn == NULL ? L"<null>" : pcszNameIn ) );
  300. HRESULT hr = S_OK; // Bug #294649
  301. BSTR bstrNewName;
  302. if ( pcszNameIn == NULL )
  303. goto InvalidArg;
  304. bstrNewName = TraceSysAllocString( pcszNameIn );
  305. if ( bstrNewName == NULL )
  306. goto OutOfMemory;
  307. if ( m_bstrName != NULL )
  308. {
  309. TraceSysFreeString( m_bstrName );
  310. }
  311. m_bstrName = bstrNewName;
  312. m_fHasNameChanged = TRUE;
  313. Cleanup:
  314. HRETURN( hr );
  315. InvalidArg:
  316. hr = THR( E_INVALIDARG );
  317. goto Cleanup;
  318. OutOfMemory:
  319. hr = E_OUTOFMEMORY;
  320. goto Cleanup;
  321. } //*** CManagedDevice::SetName( )
  322. ///////////////////////////////////////////////////////////////////////////////
  323. //++
  324. //
  325. // STDMETHODIMP
  326. // CManagedDevice::IsManaged( void )
  327. //
  328. //--
  329. ///////////////////////////////////////////////////////////////////////////////
  330. STDMETHODIMP
  331. CManagedDevice::IsManaged( void )
  332. {
  333. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  334. HRESULT hr;
  335. if ( m_fIsManaged )
  336. {
  337. hr = S_OK;
  338. }
  339. else
  340. {
  341. hr = S_FALSE;
  342. }
  343. HRETURN( hr );
  344. } //*** CManagedDevice::IsManaged( )
  345. ///////////////////////////////////////////////////////////////////////////////
  346. //++
  347. //
  348. // STDMETHODIMP
  349. // CManagedDevice::SetManaged(
  350. // BOOL fIsManagedIn
  351. // )
  352. //
  353. //--
  354. ///////////////////////////////////////////////////////////////////////////////
  355. STDMETHODIMP
  356. CManagedDevice::SetManaged(
  357. BOOL fIsManagedIn
  358. )
  359. {
  360. TraceFunc1( "[IClusCfgManagedResourceInfo] fIsManagedIn = '%s'", BOOLTOSTRING( fIsManagedIn ) );
  361. m_fIsManaged = fIsManagedIn;
  362. HRETURN( S_OK );
  363. } //*** CManagedDevice::SetManaged( )
  364. ///////////////////////////////////////////////////////////////////////////////
  365. //++
  366. //
  367. // STDMETHODIMP
  368. // CManagedDevice::IsQuorumDevice( void )
  369. //
  370. //--
  371. ///////////////////////////////////////////////////////////////////////////////
  372. STDMETHODIMP
  373. CManagedDevice::IsQuorumDevice( void )
  374. {
  375. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  376. HRESULT hr;
  377. if ( m_fIsQuorumDevice )
  378. {
  379. hr = S_OK;
  380. }
  381. else
  382. {
  383. hr = S_FALSE;
  384. }
  385. HRETURN( hr );
  386. } //*** CManagedDevice::IsQuorumDevice( )
  387. ///////////////////////////////////////////////////////////////////////////////
  388. //++
  389. //
  390. // STDMETHODIMP
  391. // CManagedDevice::SetQuorumedDevice(
  392. // BOOL fIsQuorumDeviceIn
  393. // )
  394. //
  395. //--
  396. ///////////////////////////////////////////////////////////////////////////////
  397. STDMETHODIMP
  398. CManagedDevice::SetQuorumedDevice(
  399. BOOL fIsQuorumDeviceIn
  400. )
  401. {
  402. TraceFunc1( "[IClusCfgManagedResourceInfo] fIsQuorumDeviceIn = '%s'", BOOLTOSTRING( fIsQuorumDeviceIn ) );
  403. m_fIsQuorumDevice = fIsQuorumDeviceIn;
  404. HRETURN( S_OK );
  405. } //*** CManagedDevice::SetQuorumedDevice( )
  406. ///////////////////////////////////////////////////////////////////////////////
  407. //++
  408. //
  409. // STDMETHODIMP
  410. // CManagedDevice::IsQuorumCapable( void )
  411. //
  412. //--
  413. ///////////////////////////////////////////////////////////////////////////////
  414. STDMETHODIMP
  415. CManagedDevice::IsQuorumCapable( void )
  416. {
  417. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  418. HRESULT hr;
  419. if ( m_fIsQuorumCapable )
  420. {
  421. hr = S_OK;
  422. }
  423. else
  424. {
  425. hr = S_FALSE;
  426. }
  427. HRETURN( hr );
  428. } //*** CManagedDevice::IsQuorumCapable( )
  429. ///////////////////////////////////////////////////////////////////////////////
  430. //++
  431. //
  432. // STDMETHODIMP
  433. // CManagedDevice::GetDriveLetterMappings(
  434. // SDriveLetterMapping * pdlmDriveLetterMappingOut
  435. // )
  436. //
  437. //--
  438. ///////////////////////////////////////////////////////////////////////////////
  439. STDMETHODIMP
  440. CManagedDevice::GetDriveLetterMappings(
  441. SDriveLetterMapping * pdlmDriveLetterMappingOut
  442. )
  443. {
  444. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  445. *pdlmDriveLetterMappingOut = m_dlmDriveLetterMapping;
  446. HRETURN( S_OK );
  447. } //*** CManagedDevice::GetDriveLetterMappings( )
  448. ///////////////////////////////////////////////////////////////////////////////
  449. //++
  450. //
  451. // STDMETHODIMP
  452. // CManagedDevice::SetDriveLetterMappings(
  453. // SDriveLetterMapping dlmDriveLetterMappingIn
  454. // )
  455. //
  456. //--
  457. ///////////////////////////////////////////////////////////////////////////////
  458. STDMETHODIMP
  459. CManagedDevice::SetDriveLetterMappings(
  460. SDriveLetterMapping dlmDriveLetterMappingIn
  461. )
  462. {
  463. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  464. m_dlmDriveLetterMapping = dlmDriveLetterMappingIn;
  465. HRETURN( S_OK );
  466. } //*** CManagedDevice::SetDriveLetterMappings( )
  467. ///////////////////////////////////////////////////////////////////////////////
  468. //++
  469. //
  470. // STDMETHODIMP
  471. // CManagedDevice::IsDeviceJoinable( void )
  472. //
  473. //--
  474. ///////////////////////////////////////////////////////////////////////////////
  475. STDMETHODIMP
  476. CManagedDevice::IsDeviceJoinable( void )
  477. {
  478. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  479. HRESULT hr;
  480. if ( m_fIsQuorumJoinable )
  481. {
  482. hr = S_OK;
  483. }
  484. else
  485. {
  486. hr = S_FALSE;
  487. }
  488. HRETURN( hr );
  489. } //*** CManagedDevice::IsDeviceJoinable( )
  490. ///////////////////////////////////////////////////////////////////////////////
  491. //++
  492. //
  493. // STDMETHODIMP
  494. // CManagedDevice::SetDeviceJoinable( void )
  495. //
  496. //--
  497. ///////////////////////////////////////////////////////////////////////////////
  498. STDMETHODIMP
  499. CManagedDevice::SetDeviceJoinable( BOOL fIsJoinableIn )
  500. {
  501. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  502. HRETURN( THR( E_NOTIMPL ) );
  503. } //*** CManagedDevice::SetDeviceJoinable( )
  504. //****************************************************************************
  505. //
  506. // IGatherData
  507. //
  508. //****************************************************************************
  509. //////////////////////////////////////////////////////////////////////////////
  510. //++
  511. //
  512. // STDMETHODIMP
  513. // CManagedDevice::Gather(
  514. // OBJECTCOOKIE cookieParentIn,
  515. // IUnknown * punkIn
  516. // )
  517. //
  518. //--
  519. //////////////////////////////////////////////////////////////////////////////
  520. STDMETHODIMP
  521. CManagedDevice::Gather(
  522. OBJECTCOOKIE cookieParentIn,
  523. IUnknown * punkIn
  524. )
  525. {
  526. TraceFunc( "[IGatherData]" );
  527. HRESULT hr;
  528. BSTR bstr = NULL;
  529. IClusCfgManagedResourceInfo * pccmri = NULL;
  530. //
  531. // Check parameters
  532. //
  533. if ( punkIn == NULL )
  534. goto InvalidArg;
  535. //
  536. // Find the inteface we need to gather our info.
  537. //
  538. hr = THR( punkIn->TypeSafeQI( IClusCfgManagedResourceInfo, &pccmri ) );
  539. if ( FAILED( hr ) )
  540. goto Cleanup;
  541. //
  542. // Gather UID
  543. //
  544. hr = THR( pccmri->GetUID( &m_bstrUID ) );
  545. if ( FAILED( hr ) )
  546. goto Error;
  547. TraceMemoryAddBSTR( m_bstrUID );
  548. //
  549. // Gather Name
  550. //
  551. hr = THR( pccmri->GetName( &m_bstrName ) );
  552. if ( FAILED( hr ) )
  553. goto Error;
  554. TraceMemoryAddBSTR( m_bstrName );
  555. //
  556. // Gather IsManaged
  557. //
  558. hr = STHR( pccmri->IsManaged( ) );
  559. if ( FAILED( hr ) )
  560. goto Error;
  561. if ( hr == S_OK )
  562. {
  563. m_fIsManaged = TRUE;
  564. }
  565. else
  566. {
  567. m_fIsManaged = FALSE;
  568. }
  569. //
  570. // Gather Quorum Capable
  571. //
  572. hr = STHR( pccmri->IsQuorumCapable( ) );
  573. if ( FAILED( hr ) )
  574. goto Error;
  575. if ( hr == S_OK )
  576. {
  577. m_fIsQuorumCapable = TRUE;
  578. }
  579. else
  580. {
  581. m_fIsQuorumCapable = FALSE;
  582. }
  583. //
  584. // If the device is quorumable, does it allow joins.
  585. //
  586. if(m_fIsQuorumCapable)
  587. {
  588. hr = STHR( pccmri->IsDeviceJoinable( ) );
  589. if( FAILED( hr ) )
  590. goto Error;
  591. if( hr == S_OK )
  592. {
  593. m_fIsQuorumJoinable = TRUE;
  594. }
  595. else
  596. {
  597. m_fIsQuorumJoinable = FALSE;
  598. }
  599. }
  600. else
  601. {
  602. m_fIsQuorumJoinable = FALSE;
  603. }
  604. //
  605. // Gather if resource is the quorum resource.
  606. //
  607. hr = STHR( pccmri->IsQuorumDevice( ) );
  608. if ( FAILED( hr ) )
  609. goto Cleanup;
  610. if ( hr == S_OK )
  611. {
  612. m_fIsQuorumDevice = TRUE;
  613. }
  614. else
  615. {
  616. m_fIsQuorumDevice = FALSE;
  617. }
  618. //
  619. // Gather Device Mappings
  620. //
  621. hr = STHR( pccmri->GetDriveLetterMappings( &m_dlmDriveLetterMapping ) );
  622. if ( FAILED( hr ) )
  623. goto Error;
  624. if ( hr == S_FALSE )
  625. {
  626. // Make sure this is nuked
  627. ZeroMemory( &m_dlmDriveLetterMapping, sizeof(m_dlmDriveLetterMapping) );
  628. }
  629. //
  630. // Anything else to gather??
  631. //
  632. hr = S_OK;
  633. Cleanup:
  634. if ( pccmri != NULL )
  635. {
  636. pccmri->Release( );
  637. }
  638. HRETURN( hr );
  639. Error:
  640. //
  641. // On error, invalidate all data.
  642. //
  643. if ( m_bstrUID != NULL )
  644. {
  645. TraceSysFreeString( m_bstrUID );
  646. m_bstrUID = NULL;
  647. }
  648. if ( m_bstrName != NULL )
  649. {
  650. TraceSysFreeString( m_bstrName );
  651. m_bstrName = NULL;
  652. }
  653. if ( m_bstrType != NULL )
  654. {
  655. TraceSysFreeString( m_bstrType );
  656. m_bstrType = NULL;
  657. }
  658. m_fIsManaged = FALSE;
  659. m_fIsQuorumCapable = FALSE;
  660. m_fIsQuorumJoinable = FALSE;
  661. m_fIsQuorumDevice = FALSE;
  662. ZeroMemory( &m_dlmDriveLetterMapping, sizeof( m_dlmDriveLetterMapping ) );
  663. goto Cleanup;
  664. InvalidArg:
  665. hr = THR( E_INVALIDARG );
  666. goto Cleanup;
  667. } //*** CManagedDevice::Gather( )
  668. // ************************************************************************
  669. //
  670. // IExtendObjectManager
  671. //
  672. // ************************************************************************
  673. //////////////////////////////////////////////////////////////////////////////
  674. //++
  675. //
  676. // STDMETHODIMP
  677. // CManagedDevice::FindObject(
  678. // OBJECTCOOKIE cookieIn
  679. // , REFCLSID rclsidTypeIn
  680. // , LPCWSTR pcszNameIn
  681. // , LPUNKNOWN * punkOut
  682. // )
  683. //
  684. //--
  685. //////////////////////////////////////////////////////////////////////////////
  686. STDMETHODIMP
  687. CManagedDevice::FindObject(
  688. OBJECTCOOKIE cookieIn
  689. , REFCLSID rclsidTypeIn
  690. , LPCWSTR pcszNameIn
  691. , LPUNKNOWN * ppunkOut
  692. )
  693. {
  694. TraceFunc( "[IExtendObjectManager]" );
  695. HRESULT hr = E_UNEXPECTED;
  696. //
  697. // Validate arguments.
  698. //
  699. if ( cookieIn == 0 )
  700. goto InvalidArg;
  701. if ( rclsidTypeIn != CLSID_ManagedResourceType )
  702. goto InvalidArg;
  703. if ( pcszNameIn == NULL )
  704. goto InvalidArg;
  705. if ( ppunkOut == NULL )
  706. goto InvalidPointer;
  707. hr = THR( QueryInterface( DFGUID_ManagedResource,
  708. reinterpret_cast< void ** >( ppunkOut )
  709. ) );
  710. if ( FAILED( hr ) )
  711. goto Cleanup;
  712. hr = S_OK;
  713. Cleanup:
  714. HRETURN( hr );
  715. InvalidArg:
  716. hr = THR( E_INVALIDARG );
  717. goto Cleanup;
  718. InvalidPointer:
  719. hr = THR( E_POINTER );
  720. goto Cleanup;
  721. } //*** CManagedDevice::FindObject( )