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.

848 lines
21 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1997 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // DataObj.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CDataObject class, which is the IDataObject
  10. // class used to transfer data between CluAdmin and the extension DLL
  11. // handlers.
  12. //
  13. // Author:
  14. // David Potter (davidp) June 4, 1996
  15. //
  16. // Revision History:
  17. //
  18. // Notes:
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #include "stdafx.h"
  22. #include <CluAdmEx.h>
  23. #include "DataObj.h"
  24. #include "ClusItem.h"
  25. #include "ClusItem.inl"
  26. #include "Res.h"
  27. #include "resource.h"
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. /////////////////////////////////////////////////////////////////////////////
  34. // Global Variables
  35. /////////////////////////////////////////////////////////////////////////////
  36. // Object type map.
  37. static IDS g_rgidsObjectType[] =
  38. {
  39. NULL,
  40. IDS_ITEMTYPE_CLUSTER,
  41. IDS_ITEMTYPE_NODE,
  42. IDS_ITEMTYPE_GROUP,
  43. IDS_ITEMTYPE_RESOURCE,
  44. IDS_ITEMTYPE_RESTYPE,
  45. IDS_ITEMTYPE_NETWORK,
  46. IDS_ITEMTYPE_NETIFACE
  47. };
  48. #define RGIDS_OBJECT_TYPE_SIZE sizeof(g_rgidsObjectType) / sizeof(IDS)
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CDataObject
  51. /////////////////////////////////////////////////////////////////////////////
  52. IMPLEMENT_DYNAMIC(CDataObject, CObject)
  53. /////////////////////////////////////////////////////////////////////////////
  54. //++
  55. //
  56. // CDataObject::CDataObject
  57. //
  58. // Routine Description:
  59. // Default constructor.
  60. //
  61. // Arguments:
  62. // None.
  63. //
  64. // Return Value:
  65. // None.
  66. //
  67. //--
  68. /////////////////////////////////////////////////////////////////////////////
  69. CDataObject::CDataObject(void)
  70. {
  71. m_pci = NULL;
  72. m_lcid = NULL;
  73. m_hfont = NULL;
  74. m_hicon = NULL;
  75. m_pfGetResNetName = NULL;
  76. m_pModuleState = AfxGetModuleState();
  77. ASSERT(m_pModuleState != NULL);
  78. } //*** CDataObject::CDataObject()
  79. /////////////////////////////////////////////////////////////////////////////
  80. //++
  81. //
  82. // CDataObject::~CDataObject
  83. //
  84. // Routine Description:
  85. // Destructor.
  86. //
  87. // Arguments:
  88. // None.
  89. //
  90. // Return Value:
  91. // None.
  92. //
  93. //--
  94. /////////////////////////////////////////////////////////////////////////////
  95. CDataObject::~CDataObject(void)
  96. {
  97. m_pModuleState = NULL;
  98. } //*** CDataObject::~CDataObject()
  99. /////////////////////////////////////////////////////////////////////////////
  100. //++
  101. //
  102. // CDataObject::Init
  103. //
  104. // Routine Description:
  105. // Second-phase constructor.
  106. //
  107. // Arguments:
  108. // pci [IN OUT] Cluster item for which a property sheet is being displayed.
  109. // lcid [IN] Locale ID of resources to be loaded by extension.
  110. // hfont [IN] Font to use for property page text.
  111. // hicon [IN] Icon for upper left icon control.
  112. //
  113. // Return Value:
  114. // None.
  115. //
  116. //--
  117. /////////////////////////////////////////////////////////////////////////////
  118. void CDataObject::Init(
  119. IN OUT CClusterItem * pci,
  120. IN LCID lcid,
  121. IN HFONT hfont,
  122. IN HICON hicon
  123. )
  124. {
  125. ASSERT_VALID(pci);
  126. // Save parameters.
  127. m_pci = pci;
  128. m_lcid = lcid;
  129. m_hfont = hfont;
  130. m_hicon = hicon;
  131. } //*** CDataObject::Init()
  132. /////////////////////////////////////////////////////////////////////////////
  133. //++
  134. //
  135. // CDataObject::InterfaceSupportsErrorInfo [ISupportsErrorInfo]
  136. //
  137. // Routine Description:
  138. // Determines whether the interface supports error info (???).
  139. //
  140. // Arguments:
  141. // riid [IN] Reference to the interface ID.
  142. //
  143. // Return Value:
  144. // S_OK Interface supports error info.
  145. // S_FALSE Interface does not support error info.
  146. //
  147. // Exceptions Thrown:
  148. // None.
  149. //
  150. //--
  151. /////////////////////////////////////////////////////////////////////////////
  152. STDMETHODIMP CDataObject::InterfaceSupportsErrorInfo(REFIID riid)
  153. {
  154. static const IID * rgiid[] =
  155. {
  156. &IID_IGetClusterDataInfo,
  157. &IID_IGetClusterObjectInfo,
  158. &IID_IGetClusterNodeInfo,
  159. &IID_IGetClusterGroupInfo,
  160. &IID_IGetClusterResourceInfo,
  161. };
  162. int iiid;
  163. for (iiid = 0 ; iiid < sizeof(rgiid) / sizeof(rgiid[0]) ; iiid++)
  164. {
  165. if (InlineIsEqualGUID(*rgiid[iiid], riid))
  166. return S_OK;
  167. }
  168. return S_FALSE;
  169. } //*** CDataObject::InterfaceSupportsErrorInfo()
  170. /////////////////////////////////////////////////////////////////////////////
  171. //++
  172. //
  173. // CDataObject::GetLocale [IGetClusterUIInfo]
  174. //
  175. // Routine Description:
  176. // Get the locale ID for the extension to use.
  177. //
  178. // Arguments:
  179. // None.
  180. //
  181. // Return Value:
  182. // LCID
  183. //
  184. //--
  185. /////////////////////////////////////////////////////////////////////////////
  186. STDMETHODIMP_(LCID) CDataObject::GetLocale(void)
  187. {
  188. return Lcid();
  189. } //*** CDataObject::GetLocale()
  190. /////////////////////////////////////////////////////////////////////////////
  191. //++
  192. //
  193. // CDataObject::GetFont [IGetClusterUIInfo]
  194. //
  195. // Routine Description:
  196. // Get the font to use for property pages and wizard pages.
  197. //
  198. // Arguments:
  199. // None.
  200. //
  201. // Return Value:
  202. // HFONT
  203. //
  204. //--
  205. /////////////////////////////////////////////////////////////////////////////
  206. STDMETHODIMP_(HFONT) CDataObject::GetFont(void)
  207. {
  208. return Hfont();
  209. } //*** CDataObject::GetFont()
  210. /////////////////////////////////////////////////////////////////////////////
  211. //++
  212. //
  213. // CDataObject::GetIcon [IGetClusterUIInfo]
  214. //
  215. // Routine Description:
  216. // Get the icon to use in the upper left corner of property pages
  217. // and wizard pages.
  218. //
  219. // Arguments:
  220. // None.
  221. //
  222. // Return Value:
  223. // HICON
  224. //
  225. //--
  226. /////////////////////////////////////////////////////////////////////////////
  227. STDMETHODIMP_(HICON) CDataObject::GetIcon(void)
  228. {
  229. return Hicon();
  230. } //*** CDataObject::GetIcon()
  231. /////////////////////////////////////////////////////////////////////////////
  232. //++
  233. //
  234. // CDataObject::GetClusterName [IGetClusterDataInfo]
  235. //
  236. // Routine Description:
  237. // Get the name of the cluster in which this object exists.
  238. //
  239. // Arguments:
  240. // lpszName [OUT] String in which to return the name.
  241. // pcchName [IN OUT] Maximum length of lpszName buffer on
  242. // input. Set to the total number of characters
  243. // upon return, including terminating null character.
  244. // If no lpszName buffer is not specified, the
  245. // status returned will be NOERROR. If an lpszName
  246. // buffer is specified but it is too small, the
  247. // number of characters will be returned in pcchName
  248. // and an ERROR_MORE_DATA status will be returned.
  249. //
  250. // Return Value:
  251. // NOERROR Data (or size) copied successfully.
  252. // E_INVALIDARG Invalid arguments specified.
  253. // ERROR_MORE_DATA Buffer is too small.
  254. //
  255. //--
  256. /////////////////////////////////////////////////////////////////////////////
  257. STDMETHODIMP CDataObject::GetClusterName(
  258. OUT BSTR lpszName,
  259. IN OUT LONG * pcchName
  260. )
  261. {
  262. LONG cchName = 0;
  263. LPWSTR pszReturn;
  264. AFX_MANAGE_STATE(m_pModuleState);
  265. ASSERT_VALID(Pci());
  266. ASSERT_VALID(Pci()->Pdoc());
  267. // Validate parameters.
  268. if (pcchName == NULL)
  269. return E_INVALIDARG;
  270. try
  271. {
  272. // Save the length to copy.
  273. cchName = *pcchName;
  274. *pcchName = Pci()->Pdoc()->StrName().GetLength() + 1;
  275. } // try
  276. catch (...)
  277. {
  278. return E_INVALIDARG;
  279. } // catch: anything
  280. // If only the length is being requested, return it now.
  281. if (lpszName == NULL)
  282. return NOERROR;
  283. // If a buffer is specified and it is too small, return an error.
  284. if (cchName < *pcchName)
  285. return ERROR_MORE_DATA;
  286. // Copy the data.
  287. pszReturn = lstrcpyW(lpszName, Pci()->Pdoc()->StrName());
  288. if (pszReturn == NULL)
  289. return E_INVALIDARG;
  290. return NOERROR;
  291. } //*** CDataObject::GetClusterName()
  292. /////////////////////////////////////////////////////////////////////////////
  293. //++
  294. //
  295. // CDataObject::GetClusterHandle [IGetClusterDataInfo]
  296. //
  297. // Routine Description:
  298. // Get the cluster handle for these objects.
  299. //
  300. // Arguments:
  301. // None.
  302. //
  303. // Return Value:
  304. // HCLUSTER
  305. //
  306. //--
  307. /////////////////////////////////////////////////////////////////////////////
  308. STDMETHODIMP_(HCLUSTER) CDataObject::GetClusterHandle(void)
  309. {
  310. AFX_MANAGE_STATE(m_pModuleState);
  311. ASSERT_VALID(Pci());
  312. return Pci()->Hcluster();
  313. } //*** CDataObject::GetClusterHandle()
  314. /////////////////////////////////////////////////////////////////////////////
  315. //++
  316. //
  317. // CDataObject::GetObjectCount [IGetClusterDataInfo]
  318. //
  319. // Routine Description:
  320. // Get the number of selected objects.
  321. //
  322. // Arguments:
  323. // None.
  324. //
  325. // Return Value:
  326. // cObj
  327. //
  328. //--
  329. /////////////////////////////////////////////////////////////////////////////
  330. STDMETHODIMP_(LONG) CDataObject::GetObjectCount(void)
  331. {
  332. // We only support one selected object at a time for now.
  333. return 1;
  334. } //*** CDataObject::GetObjectCount()
  335. /////////////////////////////////////////////////////////////////////////////
  336. //++
  337. //
  338. // CDataObject::GetObjectName [IGetClusterObjectInfo]
  339. //
  340. // Routine Description:
  341. // Get the name of the specified object.
  342. //
  343. // Arguments:
  344. // lObjIndex [IN] Zero-based index of the object.
  345. // lpszName [OUT] String in which to return the name.
  346. // pcchName [IN OUT] Maximum length of lpszName buffer on
  347. // input. Set to the total number of characters
  348. // upon return, including terminating null character.
  349. // If no lpszName buffer is not specified, the
  350. // status returned will be NOERROR. If an lpszName
  351. // buffer is specified but it is too small, the
  352. // number of characters will be returned in pcchName
  353. // and an ERROR_MORE_DATA status will be returned.
  354. //
  355. // Return Value:
  356. // NOERROR Data (or size) copied successfully.
  357. // E_INVALIDARG Invalid arguments specified.
  358. // ERROR_MORE_DATA Buffer is too small.
  359. //
  360. //--
  361. /////////////////////////////////////////////////////////////////////////////
  362. STDMETHODIMP CDataObject::GetObjectName(
  363. IN LONG lObjIndex,
  364. OUT BSTR lpszName,
  365. IN OUT LONG * pcchName
  366. )
  367. {
  368. LONG cchName = 0;
  369. LPWSTR pszReturn;
  370. AFX_MANAGE_STATE(m_pModuleState);
  371. ASSERT_VALID(Pci());
  372. // Validate parameters.
  373. // We only support one selected object at a time for now.
  374. if ((lObjIndex != 0) || (pcchName == NULL))
  375. return E_INVALIDARG;
  376. // Save the length to copy.
  377. try
  378. {
  379. cchName = *pcchName;
  380. *pcchName = Pci()->StrName().GetLength() + 1;
  381. } // try
  382. catch (...)
  383. {
  384. return E_INVALIDARG;
  385. } // catch: anything
  386. // If only the length is being requested, return it now.
  387. if (lpszName == NULL)
  388. return NOERROR;
  389. // If a buffer is specified and it is too small, return an error.
  390. if (cchName < *pcchName)
  391. return ERROR_MORE_DATA;
  392. // Copy the data.
  393. pszReturn = lstrcpyW(lpszName, Pci()->StrName());
  394. if (pszReturn == NULL)
  395. return E_INVALIDARG;
  396. return NOERROR;
  397. } //*** CDataObject::GetObjectName()
  398. /////////////////////////////////////////////////////////////////////////////
  399. //++
  400. //
  401. // CDataObject::GetObjectType [IGetClusterObjectInfo]
  402. //
  403. // Routine Description:
  404. // Get the cluster database registry key for the specified object.
  405. //
  406. // Arguments:
  407. // lObjIndex [IN] Zero-based index of the object.
  408. //
  409. // Return Value:
  410. // -1 Invalid argument. Call GetLastError for more information.
  411. // CLUADMEX_OBJECT_TYPE
  412. //
  413. //--
  414. /////////////////////////////////////////////////////////////////////////////
  415. STDMETHODIMP_(CLUADMEX_OBJECT_TYPE) CDataObject::GetObjectType(
  416. IN LONG lObjIndex
  417. )
  418. {
  419. int iids;
  420. AFX_MANAGE_STATE(m_pModuleState);
  421. ASSERT_VALID(Pci());
  422. // Validate parameters.
  423. // We only support one selected object at a time for now.
  424. if (lObjIndex != 0)
  425. {
  426. SetLastError((DWORD) E_INVALIDARG);
  427. return (CLUADMEX_OBJECT_TYPE) -1;
  428. } // if: invalid argument
  429. // Get the object type.
  430. for (iids = 0 ; iids < RGIDS_OBJECT_TYPE_SIZE ; iids++)
  431. {
  432. if (g_rgidsObjectType[iids] == Pci()->IdsType())
  433. return (CLUADMEX_OBJECT_TYPE) iids;
  434. } // for: each entry in the table
  435. return CLUADMEX_OT_NONE;
  436. } //*** CDataObject::GetObjectType()
  437. /////////////////////////////////////////////////////////////////////////////
  438. //++
  439. //
  440. // CDataObject::GetNodeHandle [IGetClusterNodeInfo]
  441. //
  442. // Routine Description:
  443. // Get the handle for the specified node.
  444. //
  445. // Arguments:
  446. // lObjIndex [IN] Zero-based index of the object.
  447. //
  448. // Return Value:
  449. // HNODE
  450. //
  451. //--
  452. /////////////////////////////////////////////////////////////////////////////
  453. STDMETHODIMP_(HNODE) CDataObject::GetNodeHandle(
  454. IN LONG lObjIndex
  455. )
  456. {
  457. CClusterNode * pciNode = (CClusterNode *) Pci();
  458. AFX_MANAGE_STATE(m_pModuleState);
  459. ASSERT_VALID(Pci());
  460. // Validate parameters.
  461. // We only support one selected object at a time for now.
  462. if ((lObjIndex != 0)
  463. || (Pci()->IdsType() != IDS_ITEMTYPE_NODE))
  464. {
  465. SetLastError((DWORD) E_INVALIDARG);
  466. return NULL;
  467. } // if: invalid argument
  468. ASSERT_KINDOF(CClusterNode, pciNode);
  469. return pciNode->Hnode();
  470. } //*** CDataObject::GetNodeHandle()
  471. /////////////////////////////////////////////////////////////////////////////
  472. //++
  473. //
  474. // CDataObject::GetGroupHandle [IGetClusterGroupInfo]
  475. //
  476. // Routine Description:
  477. // Get the handle for the specified group.
  478. //
  479. // Arguments:
  480. // lObjIndex [IN] Zero-based index of the object.
  481. //
  482. // Return Value:
  483. // HGROUP
  484. //
  485. //--
  486. /////////////////////////////////////////////////////////////////////////////
  487. STDMETHODIMP_(HGROUP) CDataObject::GetGroupHandle(
  488. IN LONG lObjIndex
  489. )
  490. {
  491. CGroup * pciGroup = (CGroup *) Pci();
  492. AFX_MANAGE_STATE(m_pModuleState);
  493. ASSERT_VALID(Pci());
  494. // Validate parameters.
  495. // We only support one selected object at a time for now.
  496. if ((lObjIndex != 0)
  497. || (Pci()->IdsType() != IDS_ITEMTYPE_GROUP))
  498. {
  499. SetLastError((DWORD) E_INVALIDARG);
  500. return NULL;
  501. } // if: invalid argument
  502. ASSERT_KINDOF(CGroup, pciGroup);
  503. return pciGroup->Hgroup();
  504. } //*** CDataObject::GetGroupHandle()
  505. /////////////////////////////////////////////////////////////////////////////
  506. //++
  507. //
  508. // CDataObject::GetResourceHandle [IGetClusterResourceInfo]
  509. //
  510. // Routine Description:
  511. // Get the handle for the specified resource.
  512. //
  513. // Arguments:
  514. // lObjIndex [IN] Zero-based index of the object.
  515. //
  516. // Return Value:
  517. // HRESOURCE
  518. //
  519. //--
  520. /////////////////////////////////////////////////////////////////////////////
  521. STDMETHODIMP_(HRESOURCE) CDataObject::GetResourceHandle(
  522. IN LONG lObjIndex
  523. )
  524. {
  525. CResource * pciRes = (CResource *) Pci();
  526. AFX_MANAGE_STATE(m_pModuleState);
  527. ASSERT_VALID(Pci());
  528. // Validate parameters.
  529. // We only support one selected object at a time for now.
  530. if ((lObjIndex != 0)
  531. || (Pci()->IdsType() != IDS_ITEMTYPE_RESOURCE))
  532. {
  533. SetLastError((DWORD) E_INVALIDARG);
  534. return NULL;
  535. } // if: invalid argument
  536. ASSERT_KINDOF(CResource, pciRes);
  537. return pciRes->Hresource();
  538. } //*** CDataObject::GetResourceHandle()
  539. /////////////////////////////////////////////////////////////////////////////
  540. //++
  541. //
  542. // CDataObject::GetResourceTypeName [IGetClusterResourceInfo]
  543. //
  544. // Routine Description:
  545. // Returns the name of the resource type of the specified resource.
  546. //
  547. // Arguments:
  548. // lObjIndex [IN] Zero-based index of the object.
  549. // lpszResTypeName [OUT] String in which to return the resource type name.
  550. // pcchResTypeName [IN OUT] Maximum length of lpszResTypeName buffer on
  551. // input. Set to the total number of characters
  552. // upon return, including terminating null character.
  553. // If no lpszResTypeName buffer is not specified, the
  554. // status returned will be NOERROR. If an lpszResTypeName
  555. // buffer is specified but it is too small, the
  556. // number of characters will be returned in pcchResTypeName
  557. // and an ERROR_MORE_DATA status will be returned.
  558. //
  559. // Return Value:
  560. // NOERROR Data (or size) copied successfully.
  561. // E_INVALIDARG Invalid arguments specified.
  562. // ERROR_MORE_DATA Buffer is too small.
  563. //
  564. //--
  565. /////////////////////////////////////////////////////////////////////////////
  566. STDMETHODIMP CDataObject::GetResourceTypeName(
  567. IN LONG lObjIndex,
  568. OUT BSTR lpszResTypeName,
  569. IN OUT LONG * pcchResTypeName
  570. )
  571. {
  572. LONG cchResTypeName = 0;
  573. CResource * pciRes = (CResource *) Pci();
  574. CString const * pstrResourceTypeName;
  575. LPWSTR pszReturn;
  576. AFX_MANAGE_STATE(m_pModuleState);
  577. ASSERT_VALID(Pci());
  578. // Validate parameters.
  579. // We only support one selected object at a time for now.
  580. if ((lObjIndex != 0)
  581. || (pcchResTypeName == NULL)
  582. || (Pci()->IdsType() != IDS_ITEMTYPE_RESOURCE))
  583. {
  584. return E_INVALIDARG;
  585. } // if: invalid argument
  586. ASSERT_KINDOF(CResource, pciRes);
  587. // Get a pointer to the name to copy.
  588. if (pciRes->PciResourceType() != NULL)
  589. {
  590. ASSERT_VALID(pciRes->PciResourceType());
  591. pstrResourceTypeName = &pciRes->PciResourceType()->StrName();
  592. } // if: valid resource type pointer
  593. else
  594. pstrResourceTypeName = &pciRes->StrResourceType();
  595. // Save the length to copy.
  596. try
  597. {
  598. cchResTypeName = *pcchResTypeName;
  599. *pcchResTypeName = pstrResourceTypeName->GetLength() + 1;
  600. } // try
  601. catch (...)
  602. {
  603. return E_INVALIDARG;
  604. } // catch: anything
  605. // If only the length is being requested, return it now.
  606. if (lpszResTypeName == NULL)
  607. return NOERROR;
  608. // If a buffer is specified and it is too small, return an error.
  609. if (cchResTypeName < *pcchResTypeName)
  610. return ERROR_MORE_DATA;
  611. // Copy the data.
  612. pszReturn = lstrcpyW(lpszResTypeName, *pstrResourceTypeName);
  613. if (pszReturn == NULL)
  614. return E_INVALIDARG;
  615. return NOERROR;
  616. } //*** CDataObject::GetResourceTypeName()
  617. /////////////////////////////////////////////////////////////////////////////
  618. //++
  619. //
  620. // CDataObject::GetResourceNetworkName [IGetClusterResourceInfo]
  621. //
  622. // Routine Description:
  623. // Returns the name of the network name of the first Network Name
  624. // resource on which the specified resource depends.
  625. //
  626. // Arguments:
  627. // lObjIndex [IN] Zero-based index of the object.
  628. // lpszNetName [OUT] String in which to return the network name.
  629. // pcchNetName [IN OUT] Points to a variable that specifies the
  630. // maximum size, in characters, of the buffer. This
  631. // value should be large enough to contain
  632. // MAX_COMPUTERNAME_LENGTH + 1 characters. Upon
  633. // return it contains the actual number of characters
  634. // copied.
  635. //
  636. // Return Value:
  637. // TRUE Data (or size) copied successfully.
  638. // FALSE Error getting information. GetLastError() returns:
  639. // E_INVALIDARG Invalid arguments specified.
  640. //
  641. //--
  642. /////////////////////////////////////////////////////////////////////////////
  643. STDMETHODIMP_(BOOL) CDataObject::GetResourceNetworkName(
  644. IN LONG lObjIndex,
  645. OUT BSTR lpszNetName,
  646. IN OUT ULONG * pcchNetName
  647. )
  648. {
  649. BOOL bSuccess = FALSE;
  650. CResource * pciRes = (CResource *) Pci();
  651. AFX_MANAGE_STATE(m_pModuleState);
  652. ASSERT_VALID(Pci());
  653. try
  654. {
  655. // Validate parameters.
  656. // We only support one selected object at a time for now.
  657. if ((lObjIndex != 0)
  658. || (pcchNetName == NULL)
  659. || (*pcchNetName < MAX_COMPUTERNAME_LENGTH)
  660. || (Pci()->IdsType() != IDS_ITEMTYPE_RESOURCE))
  661. {
  662. SetLastError((DWORD) E_INVALIDARG);
  663. return FALSE;
  664. } // if: invalid argument
  665. ASSERT_KINDOF(CResource, pciRes);
  666. // If there is a function for getting this information, call it.
  667. // Otherwise, handle it ourselves.
  668. if (PfGetResNetName() != NULL)
  669. bSuccess = (*PfGetResNetName())(lpszNetName, pcchNetName, m_pvGetResNetNameContext);
  670. else
  671. bSuccess = pciRes->BGetNetworkName(lpszNetName, pcchNetName);
  672. } // try
  673. catch (...)
  674. {
  675. bSuccess = FALSE;
  676. SetLastError((DWORD) E_INVALIDARG);
  677. } // catch: anything
  678. return bSuccess;
  679. } //*** CDataObject::GetResourceNetworkName()
  680. /////////////////////////////////////////////////////////////////////////////
  681. //++
  682. //
  683. // CDataObject::GetNetworkHandle [IGetClusterNetworkInfo]
  684. //
  685. // Routine Description:
  686. // Get the handle for the specified network.
  687. //
  688. // Arguments:
  689. // lObjIndex [IN] Zero-based index of the object.
  690. //
  691. // Return Value:
  692. // HNETWORK
  693. //
  694. //--
  695. /////////////////////////////////////////////////////////////////////////////
  696. STDMETHODIMP_(HNETWORK) CDataObject::GetNetworkHandle(
  697. IN LONG lObjIndex
  698. )
  699. {
  700. CNetwork * pciNetwork = (CNetwork *) Pci();
  701. AFX_MANAGE_STATE(m_pModuleState);
  702. ASSERT_VALID(Pci());
  703. // Validate parameters.
  704. // We only support one selected object at a time for now.
  705. if ((lObjIndex != 0)
  706. || (Pci()->IdsType() != IDS_ITEMTYPE_NETWORK))
  707. {
  708. SetLastError((DWORD) E_INVALIDARG);
  709. return NULL;
  710. } // if: invalid argument
  711. ASSERT_KINDOF(CNetwork, pciNetwork);
  712. return pciNetwork->Hnetwork();
  713. } //*** CDataObject::GetNetworkHandle()
  714. /////////////////////////////////////////////////////////////////////////////
  715. //++
  716. //
  717. // CDataObject::GetNetInterfaceHandle [IGetClusterNetInterfaceInfo]
  718. //
  719. // Routine Description:
  720. // Get the handle for the specified network interface.
  721. //
  722. // Arguments:
  723. // lObjIndex [IN] Zero-based index of the object.
  724. //
  725. // Return Value:
  726. // HNETINTERFACE
  727. //
  728. //--
  729. /////////////////////////////////////////////////////////////////////////////
  730. STDMETHODIMP_(HNETINTERFACE) CDataObject::GetNetInterfaceHandle(
  731. IN LONG lObjIndex
  732. )
  733. {
  734. CNetInterface * pciNetIFace = (CNetInterface *) Pci();
  735. AFX_MANAGE_STATE(m_pModuleState);
  736. ASSERT_VALID(Pci());
  737. // Validate parameters.
  738. // We only support one selected object at a time for now.
  739. if ((lObjIndex != 0)
  740. || (Pci()->IdsType() != IDS_ITEMTYPE_NETIFACE))
  741. {
  742. SetLastError((DWORD) E_INVALIDARG);
  743. return NULL;
  744. } // if: invalid argument
  745. ASSERT_KINDOF(CNetwork, pciNetIFace);
  746. return pciNetIFace->Hnetiface();
  747. } //*** CDataObject::GetNetInterfaceHandle()