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.

2543 lines
47 KiB

  1. #include "nds.hxx"
  2. #pragma hdrstop
  3. //////////////////////////////////////////////////////////////////////////
  4. HRESULT
  5. ConvertStringArrayToSafeBstrArray(
  6. LPWSTR *prgszArray,
  7. DWORD dwNumElement,
  8. VARIANT *pvarSafeArray
  9. )
  10. {
  11. HRESULT hr = S_OK;
  12. SAFEARRAY *aList = NULL;
  13. SAFEARRAYBOUND aBound;
  14. CHAR HUGEP *pArray = NULL;
  15. long i;
  16. BSTR bstrAddress;
  17. if ((!prgszArray) || (!pvarSafeArray)) {
  18. hr = E_FAIL;
  19. BAIL_ON_FAILURE(hr);
  20. }
  21. aBound.lLbound = 0;
  22. aBound.cElements = dwNumElement;
  23. aList = SafeArrayCreate( VT_VARIANT, 1, &aBound );
  24. if ( aList == NULL ) {
  25. hr = E_OUTOFMEMORY;
  26. BAIL_ON_FAILURE(hr);
  27. }
  28. for ( i = 0; i < (long)dwNumElement; i++ ) {
  29. VARIANT v;
  30. VariantInit(&v);
  31. v.vt = VT_BSTR;
  32. hr = ADsAllocString(
  33. prgszArray[i],
  34. &v.bstrVal
  35. );
  36. BAIL_ON_FAILURE(hr);
  37. hr = SafeArrayPutElement( aList, &i, &v);
  38. BAIL_ON_FAILURE(hr);
  39. VariantClear(&v);
  40. }
  41. V_VT(pvarSafeArray) = VT_ARRAY | VT_VARIANT;
  42. V_ARRAY(pvarSafeArray) = aList;
  43. RRETURN(hr);
  44. error:
  45. if ( aList ) {
  46. SafeArrayDestroy( aList );
  47. }
  48. RRETURN(hr);
  49. }
  50. HRESULT
  51. ConvertSafeBstrArrayToStringArray(
  52. VARIANT varSafeArray,
  53. LPWSTR **prgszArray,
  54. PDWORD pdwNumElement
  55. )
  56. {
  57. HRESULT hr = S_OK;
  58. DWORD dwSLBound = 0;
  59. DWORD dwSUBound = 0;
  60. DWORD dwNumVariants = 0;
  61. DWORD i = 0;
  62. LPWSTR* rgszArray = NULL;
  63. SAFEARRAY * pArray = NULL;
  64. if ((!prgszArray ) || (!pdwNumElement)) {
  65. hr = E_FAIL;
  66. BAIL_ON_FAILURE(hr);
  67. }
  68. *pdwNumElement = 0;
  69. *prgszArray = NULL;
  70. if(!((V_VT(&varSafeArray) & VT_VARIANT) && V_ISARRAY(&varSafeArray)))
  71. RRETURN(E_FAIL);
  72. //
  73. // This handles by-ref and regular SafeArrays.
  74. //
  75. if (V_VT(&varSafeArray) & VT_BYREF)
  76. pArray = *(V_ARRAYREF(&varSafeArray));
  77. else
  78. pArray = V_ARRAY(&varSafeArray);
  79. //
  80. // Check that there is only one dimension in this array
  81. //
  82. if (pArray->cDims != 1) {
  83. hr = E_FAIL;
  84. BAIL_ON_FAILURE(hr);
  85. }
  86. //
  87. // Check that there is at least one element in this array
  88. //
  89. if (pArray->rgsabound[0].cElements == 0){
  90. RRETURN(S_OK); // Return success and null array
  91. }
  92. //
  93. // We know that this is a valid single dimension array
  94. //
  95. hr = SafeArrayGetLBound(pArray,
  96. 1,
  97. (long FAR *)&dwSLBound
  98. );
  99. BAIL_ON_FAILURE(hr);
  100. hr = SafeArrayGetUBound(pArray,
  101. 1,
  102. (long FAR *)&dwSUBound
  103. );
  104. BAIL_ON_FAILURE(hr);
  105. dwNumVariants = dwSUBound - dwSLBound + 1;
  106. rgszArray = (LPWSTR*)AllocADsMem(
  107. sizeof(LPWSTR)*dwNumVariants
  108. );
  109. if (!rgszArray) {
  110. hr = E_OUTOFMEMORY;
  111. BAIL_ON_FAILURE(hr);
  112. }
  113. if ((V_VT(&varSafeArray) & VT_VARIANT) == VT_BSTR) {
  114. BSTR bstrElement;
  115. for (i = dwSLBound; i <= dwSUBound; i++) {
  116. hr = SafeArrayGetElement(pArray,
  117. (long FAR *)&i,
  118. &bstrElement
  119. );
  120. BAIL_ON_FAILURE(hr);
  121. rgszArray[i-dwSLBound] = AllocADsStr(bstrElement);
  122. if (!rgszArray[i-dwSLBound]) {
  123. hr = E_OUTOFMEMORY;
  124. }
  125. BAIL_ON_FAILURE(hr);
  126. }
  127. }
  128. else {
  129. VARIANT varElement;
  130. for (i = dwSLBound; i <= dwSUBound; i++) {
  131. VariantInit(&varElement);
  132. hr = SafeArrayGetElement(pArray,
  133. (long FAR *)&i,
  134. &varElement
  135. );
  136. BAIL_ON_FAILURE(hr);
  137. rgszArray[i-dwSLBound] = AllocADsStr(V_BSTR(&varElement));
  138. if (!rgszArray[i-dwSLBound]) {
  139. hr = E_OUTOFMEMORY;
  140. }
  141. BAIL_ON_FAILURE(hr);
  142. VariantClear(&varElement);
  143. }
  144. }
  145. *prgszArray = rgszArray;
  146. *pdwNumElement = dwNumVariants;
  147. RRETURN(hr);
  148. error:
  149. if (rgszArray) {
  150. FreeADsMem(rgszArray);
  151. }
  152. RRETURN(hr);
  153. }
  154. HRESULT
  155. ConvertBinaryArrayToSafeVariantArray(
  156. POctetString *prgArray,
  157. DWORD dwNumElement,
  158. VARIANT *pvarSafeArray
  159. )
  160. {
  161. HRESULT hr = S_OK;
  162. SAFEARRAY *aList = NULL;
  163. SAFEARRAYBOUND aBound;
  164. CHAR HUGEP *pArray = NULL;
  165. long i;
  166. VARIANT var;
  167. if ((!prgArray) || (!pvarSafeArray)) {
  168. hr = E_FAIL;
  169. BAIL_ON_FAILURE(hr);
  170. }
  171. aBound.lLbound = 0;
  172. aBound.cElements = dwNumElement;
  173. aList = SafeArrayCreate( VT_VARIANT, 1, &aBound );
  174. if ( aList == NULL )
  175. {
  176. hr = E_OUTOFMEMORY;
  177. BAIL_ON_FAILURE(hr);
  178. }
  179. for ( i = 0; i < (long)dwNumElement; i++ )
  180. {
  181. hr = BinaryToVariant(
  182. (prgArray[i])->Length,
  183. (prgArray[i])->Value,
  184. &var);
  185. BAIL_ON_FAILURE(hr);
  186. hr = SafeArrayPutElement( aList, &i, &var);
  187. BAIL_ON_FAILURE(hr);
  188. }
  189. V_VT(pvarSafeArray) = VT_ARRAY | VT_VARIANT;
  190. V_ARRAY(pvarSafeArray) = aList;
  191. RRETURN(hr);
  192. error:
  193. if ( aList )
  194. SafeArrayDestroy( aList );
  195. RRETURN(hr);
  196. }
  197. HRESULT
  198. ConvertSafeVariantArrayToBinaryArray(
  199. VARIANT varSafeArray,
  200. POctetString **prgArray,
  201. PDWORD pdwNumElement
  202. )
  203. {
  204. HRESULT hr = S_OK;
  205. DWORD dwSLBound = 0;
  206. DWORD dwSUBound = 0;
  207. LONG cIterations = 0;
  208. DWORD dwNumVariants = 0;
  209. DWORD i = 0;
  210. POctetString *rgArray = NULL;
  211. SAFEARRAY * pArray = NULL;
  212. VARIANT var;
  213. if ((!prgArray ) || (!pdwNumElement)) {
  214. hr = E_FAIL;
  215. BAIL_ON_FAILURE(hr);
  216. }
  217. *pdwNumElement = 0;
  218. *prgArray = NULL;
  219. if(!((V_VT(&varSafeArray) & VT_VARIANT) && V_ISARRAY(&varSafeArray)))
  220. RRETURN(E_FAIL);
  221. //
  222. // This handles by-ref and regular SafeArrays.
  223. //
  224. if (V_VT(&varSafeArray) & VT_BYREF)
  225. pArray = *(V_ARRAYREF(&varSafeArray));
  226. else
  227. pArray = V_ARRAY(&varSafeArray);
  228. //
  229. // Check that there is only one dimension in this array
  230. //
  231. if (pArray->cDims != 1) {
  232. hr = E_FAIL;
  233. BAIL_ON_FAILURE(hr);
  234. }
  235. //
  236. // Check that there is at least one element in this array
  237. //
  238. if (pArray->rgsabound[0].cElements == 0){
  239. RRETURN(S_OK); // Return success and null array
  240. }
  241. //
  242. // We know that this is a valid single dimension array
  243. //
  244. hr = SafeArrayGetLBound(pArray,
  245. 1,
  246. (long FAR *)&dwSLBound
  247. );
  248. BAIL_ON_FAILURE(hr);
  249. hr = SafeArrayGetUBound(pArray,
  250. 1,
  251. (long FAR *)&dwSUBound
  252. );
  253. BAIL_ON_FAILURE(hr);
  254. dwNumVariants = dwSUBound - dwSLBound + 1;
  255. rgArray = (POctetString*)AllocADsMem(
  256. sizeof(POctetString)*dwNumVariants
  257. );
  258. if (!rgArray) {
  259. hr = E_OUTOFMEMORY;
  260. BAIL_ON_FAILURE(hr);
  261. }
  262. for (i = dwSLBound; i <= dwSUBound; i++) {
  263. rgArray[i-dwSLBound] = (POctetString)AllocADsMem(sizeof(OctetString));
  264. if (!rgArray[i-dwSLBound]) {
  265. hr = E_OUTOFMEMORY;
  266. BAIL_ON_FAILURE(hr);
  267. }
  268. rgArray[i-dwSLBound]->Value = NULL;
  269. cIterations++;
  270. VariantInit(&var);
  271. hr = SafeArrayGetElement(pArray,
  272. (long FAR *)&i,
  273. &var
  274. );
  275. BAIL_ON_FAILURE(hr);
  276. hr = VariantToBinary(
  277. &var,
  278. &(rgArray[i-dwSLBound]->Length),
  279. &(rgArray[i-dwSLBound]->Value));
  280. BAIL_ON_FAILURE(hr);
  281. }
  282. *prgArray = rgArray;
  283. *pdwNumElement = dwNumVariants;
  284. RRETURN(hr);
  285. error:
  286. if (rgArray) {
  287. for (i = dwSLBound; i < dwSLBound + cIterations; i++) {
  288. if (rgArray[i-dwSLBound]) {
  289. if (rgArray[i-dwSLBound]->Value)
  290. FreeADsMem(rgArray[i-dwSLBound]->Value);
  291. FreeADsMem(rgArray[i-dwSLBound]);
  292. }
  293. }
  294. FreeADsMem(rgArray);
  295. }
  296. RRETURN(hr);
  297. }
  298. DEFINE_IDispatch_Implementation(CCaseIgnoreList)
  299. CCaseIgnoreList::CCaseIgnoreList():
  300. _pDispMgr(NULL),
  301. _rgszCaseIgnoreList(NULL),
  302. _dwNumElement(0)
  303. {
  304. ENLIST_TRACKING(CCaseIgnoreList);
  305. }
  306. HRESULT
  307. CCaseIgnoreList::CreateCaseIgnoreList(
  308. REFIID riid,
  309. void **ppvObj
  310. )
  311. {
  312. CCaseIgnoreList FAR * pCaseIgnoreList = NULL;
  313. HRESULT hr = S_OK;
  314. hr = AllocateCaseIgnoreListObject(&pCaseIgnoreList);
  315. BAIL_ON_FAILURE(hr);
  316. hr = pCaseIgnoreList->QueryInterface(riid, ppvObj);
  317. BAIL_ON_FAILURE(hr);
  318. pCaseIgnoreList->Release();
  319. RRETURN(hr);
  320. error:
  321. delete pCaseIgnoreList;
  322. RRETURN(hr);
  323. }
  324. CCaseIgnoreList::~CCaseIgnoreList( )
  325. {
  326. delete _pDispMgr;
  327. if (_rgszCaseIgnoreList) {
  328. long i;
  329. for (i=0;i<(long)_dwNumElement;i++) {
  330. if (_rgszCaseIgnoreList[i]) {
  331. FreeADsStr(_rgszCaseIgnoreList[i]);
  332. }
  333. }
  334. FreeADsMem(_rgszCaseIgnoreList);
  335. }
  336. }
  337. STDMETHODIMP
  338. CCaseIgnoreList::QueryInterface(
  339. REFIID iid,
  340. LPVOID FAR* ppv
  341. )
  342. {
  343. if (IsEqualIID(iid, IID_IUnknown))
  344. {
  345. *ppv = (IADsCaseIgnoreList FAR *) this;
  346. }
  347. else if (IsEqualIID(iid, IID_IADsCaseIgnoreList))
  348. {
  349. *ppv = (IADsCaseIgnoreList FAR *) this;
  350. }
  351. else if (IsEqualIID(iid, IID_IDispatch))
  352. {
  353. *ppv = (IADsCaseIgnoreList FAR *) this;
  354. }
  355. else
  356. {
  357. *ppv = NULL;
  358. return E_NOINTERFACE;
  359. }
  360. AddRef();
  361. return NOERROR;
  362. }
  363. HRESULT
  364. CCaseIgnoreList::AllocateCaseIgnoreListObject(
  365. CCaseIgnoreList ** ppCaseIgnoreList
  366. )
  367. {
  368. CCaseIgnoreList FAR * pCaseIgnoreList = NULL;
  369. CDispatchMgr FAR * pDispMgr = NULL;
  370. HRESULT hr = S_OK;
  371. pCaseIgnoreList = new CCaseIgnoreList();
  372. if (pCaseIgnoreList == NULL) {
  373. hr = E_OUTOFMEMORY;
  374. }
  375. BAIL_ON_FAILURE(hr);
  376. pDispMgr = new CDispatchMgr;
  377. if (pDispMgr == NULL) {
  378. hr = E_OUTOFMEMORY;
  379. }
  380. BAIL_ON_FAILURE(hr);
  381. hr = LoadTypeInfoEntry(
  382. pDispMgr,
  383. LIBID_ADs,
  384. IID_IADsCaseIgnoreList,
  385. (IADsCaseIgnoreList *)pCaseIgnoreList,
  386. DISPID_REGULAR
  387. );
  388. BAIL_ON_FAILURE(hr);
  389. pCaseIgnoreList->_pDispMgr = pDispMgr;
  390. *ppCaseIgnoreList = pCaseIgnoreList;
  391. RRETURN(hr);
  392. error:
  393. delete pDispMgr;
  394. RRETURN(hr);
  395. }
  396. STDMETHODIMP
  397. CCaseIgnoreList::get_CaseIgnoreList(THIS_ VARIANT FAR * pVarDestObject)
  398. {
  399. HRESULT hr = S_OK;
  400. hr = ConvertStringArrayToSafeBstrArray(
  401. _rgszCaseIgnoreList,
  402. _dwNumElement,
  403. pVarDestObject);
  404. RRETURN(hr);
  405. }
  406. STDMETHODIMP
  407. CCaseIgnoreList::put_CaseIgnoreList(THIS_ VARIANT VarSrcObject)
  408. {
  409. HRESULT hr = S_OK;
  410. if (_rgszCaseIgnoreList) {
  411. long i;
  412. for (i=0;i<(long)_dwNumElement;i++) {
  413. if (_rgszCaseIgnoreList[i]) {
  414. FreeADsStr(_rgszCaseIgnoreList[i]);
  415. }
  416. }
  417. FreeADsMem(_rgszCaseIgnoreList);
  418. _rgszCaseIgnoreList = NULL;
  419. _dwNumElement = 0;
  420. }
  421. hr = ConvertSafeBstrArrayToStringArray(
  422. VarSrcObject,
  423. &_rgszCaseIgnoreList,
  424. &_dwNumElement);
  425. RRETURN(hr);
  426. }
  427. DEFINE_IDispatch_Implementation(CFaxNumber)
  428. CFaxNumber::CFaxNumber():
  429. _pDispMgr(NULL),
  430. _szTelephoneNumber(NULL),
  431. _NumberOfBits(0),
  432. _Parameters(NULL)
  433. {
  434. ENLIST_TRACKING(CFaxNumber);
  435. }
  436. HRESULT
  437. CFaxNumber::CreateFaxNumber(
  438. REFIID riid,
  439. void **ppvObj
  440. )
  441. {
  442. CFaxNumber FAR * pFaxNumber = NULL;
  443. HRESULT hr = S_OK;
  444. hr = AllocateFaxNumberObject(&pFaxNumber);
  445. BAIL_ON_FAILURE(hr);
  446. hr = pFaxNumber->QueryInterface(riid, ppvObj);
  447. BAIL_ON_FAILURE(hr);
  448. pFaxNumber->Release();
  449. RRETURN(hr);
  450. error:
  451. delete pFaxNumber;
  452. RRETURN(hr);
  453. }
  454. CFaxNumber::~CFaxNumber( )
  455. {
  456. delete _pDispMgr;
  457. if (_szTelephoneNumber) {
  458. FreeADsStr(_szTelephoneNumber);
  459. }
  460. if (_Parameters) {
  461. FreeADsMem(_Parameters);
  462. }
  463. }
  464. STDMETHODIMP
  465. CFaxNumber::QueryInterface(
  466. REFIID iid,
  467. LPVOID FAR* ppv
  468. )
  469. {
  470. if (IsEqualIID(iid, IID_IUnknown))
  471. {
  472. *ppv = (IADsFaxNumber FAR *) this;
  473. }
  474. else if (IsEqualIID(iid, IID_IADsFaxNumber))
  475. {
  476. *ppv = (IADsFaxNumber FAR *) this;
  477. }
  478. else if (IsEqualIID(iid, IID_IDispatch))
  479. {
  480. *ppv = (IADsFaxNumber FAR *) this;
  481. }
  482. else
  483. {
  484. *ppv = NULL;
  485. return E_NOINTERFACE;
  486. }
  487. AddRef();
  488. return NOERROR;
  489. }
  490. HRESULT
  491. CFaxNumber::AllocateFaxNumberObject(
  492. CFaxNumber ** ppFaxNumber
  493. )
  494. {
  495. CFaxNumber FAR * pFaxNumber = NULL;
  496. CDispatchMgr FAR * pDispMgr = NULL;
  497. HRESULT hr = S_OK;
  498. pFaxNumber = new CFaxNumber();
  499. if (pFaxNumber == NULL) {
  500. hr = E_OUTOFMEMORY;
  501. }
  502. BAIL_ON_FAILURE(hr);
  503. pDispMgr = new CDispatchMgr;
  504. if (pDispMgr == NULL) {
  505. hr = E_OUTOFMEMORY;
  506. }
  507. BAIL_ON_FAILURE(hr);
  508. hr = LoadTypeInfoEntry(
  509. pDispMgr,
  510. LIBID_ADs,
  511. IID_IADsFaxNumber,
  512. (IADsFaxNumber *)pFaxNumber,
  513. DISPID_REGULAR
  514. );
  515. BAIL_ON_FAILURE(hr);
  516. pFaxNumber->_pDispMgr = pDispMgr;
  517. *ppFaxNumber = pFaxNumber;
  518. RRETURN(hr);
  519. error:
  520. delete pDispMgr;
  521. RRETURN(hr);
  522. }
  523. STDMETHODIMP
  524. CFaxNumber::get_Parameters(THIS_ VARIANT FAR * pVarDestObject)
  525. {
  526. HRESULT hr = S_OK;
  527. SAFEARRAY *aList = NULL;
  528. SAFEARRAYBOUND aBound;
  529. CHAR HUGEP *pArray = NULL;
  530. aBound.lLbound = 0;
  531. aBound.cElements = _NumberOfBits;
  532. aList = SafeArrayCreate( VT_UI1, 1, &aBound );
  533. if ( aList == NULL ) {
  534. hr = E_OUTOFMEMORY;
  535. BAIL_ON_FAILURE(hr);
  536. }
  537. hr = SafeArrayAccessData( aList,
  538. (void HUGEP * FAR *) &pArray );
  539. BAIL_ON_FAILURE(hr);
  540. memcpy( pArray,
  541. _Parameters,
  542. aBound.cElements );
  543. SafeArrayUnaccessData( aList );
  544. V_VT(pVarDestObject) = VT_ARRAY | VT_UI1;
  545. V_ARRAY(pVarDestObject) = aList;
  546. RRETURN(hr);
  547. error:
  548. if ( aList ) {
  549. SafeArrayDestroy( aList );
  550. }
  551. RRETURN(hr);
  552. }
  553. STDMETHODIMP
  554. CFaxNumber::put_Parameters(THIS_ VARIANT VarSrcObject)
  555. {
  556. HRESULT hr = S_OK;
  557. LONG dwSLBound = 0;
  558. LONG dwSUBound = 0;
  559. CHAR HUGEP *pArray = NULL;
  560. VARIANT *pVarSrcObject = &VarSrcObject;
  561. if (_Parameters) {
  562. FreeADsMem(_Parameters);
  563. }
  564. if( pVarSrcObject->vt != (VT_ARRAY | VT_UI1)) {
  565. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  566. }
  567. hr = SafeArrayGetLBound(V_ARRAY(pVarSrcObject),
  568. 1,
  569. (long FAR *) &dwSLBound );
  570. BAIL_ON_FAILURE(hr);
  571. hr = SafeArrayGetUBound(V_ARRAY(pVarSrcObject),
  572. 1,
  573. (long FAR *) &dwSUBound );
  574. BAIL_ON_FAILURE(hr);
  575. _Parameters =
  576. (BYTE*) AllocADsMem( dwSUBound - dwSLBound + 1);
  577. if ( _Parameters == NULL) {
  578. hr = E_OUTOFMEMORY;
  579. BAIL_ON_FAILURE(hr);
  580. }
  581. _NumberOfBits = dwSUBound - dwSLBound + 1;
  582. hr = SafeArrayAccessData( V_ARRAY(pVarSrcObject),
  583. (void HUGEP * FAR *) &pArray );
  584. BAIL_ON_FAILURE(hr);
  585. memcpy( _Parameters,
  586. pArray,
  587. _NumberOfBits);
  588. SafeArrayUnaccessData( V_ARRAY(pVarSrcObject) );
  589. error:
  590. RRETURN(hr);
  591. }
  592. STDMETHODIMP
  593. CFaxNumber::get_TelephoneNumber(THIS_ BSTR FAR * retval)
  594. {
  595. HRESULT hr = S_OK;
  596. hr = ADsAllocString(_szTelephoneNumber,
  597. retval);
  598. RRETURN(hr);
  599. }
  600. STDMETHODIMP
  601. CFaxNumber::put_TelephoneNumber(THIS_ BSTR bstrTelephoneNumber)
  602. {
  603. if (_szTelephoneNumber) {
  604. FreeADsStr(_szTelephoneNumber);
  605. }
  606. _szTelephoneNumber = AllocADsStr(bstrTelephoneNumber);
  607. if (!_szTelephoneNumber) {
  608. RRETURN(E_OUTOFMEMORY);
  609. }
  610. RRETURN(S_OK);
  611. }
  612. DEFINE_IDispatch_Implementation(CNetAddress)
  613. CNetAddress::CNetAddress():
  614. _pDispMgr(NULL),
  615. _dwAddressType(0),
  616. _dwAddressLength(0),
  617. _pbAddress(NULL)
  618. {
  619. ENLIST_TRACKING(CNetAddress);
  620. }
  621. HRESULT
  622. CNetAddress::CreateNetAddress(
  623. REFIID riid,
  624. void **ppvObj
  625. )
  626. {
  627. CNetAddress FAR * pNetAddress = NULL;
  628. HRESULT hr = S_OK;
  629. hr = AllocateNetAddressObject(&pNetAddress);
  630. BAIL_ON_FAILURE(hr);
  631. hr = pNetAddress->QueryInterface(riid, ppvObj);
  632. BAIL_ON_FAILURE(hr);
  633. pNetAddress->Release();
  634. RRETURN(hr);
  635. error:
  636. delete pNetAddress;
  637. RRETURN(hr);
  638. }
  639. CNetAddress::~CNetAddress( )
  640. {
  641. delete _pDispMgr;
  642. if (_pbAddress) {
  643. FreeADsMem(_pbAddress);
  644. }
  645. }
  646. STDMETHODIMP
  647. CNetAddress::QueryInterface(
  648. REFIID iid,
  649. LPVOID FAR* ppv
  650. )
  651. {
  652. if (IsEqualIID(iid, IID_IUnknown))
  653. {
  654. *ppv = (IADsNetAddress FAR *) this;
  655. }
  656. else if (IsEqualIID(iid, IID_IADsNetAddress))
  657. {
  658. *ppv = (IADsNetAddress FAR *) this;
  659. }
  660. else if (IsEqualIID(iid, IID_IDispatch))
  661. {
  662. *ppv = (IADsNetAddress FAR *) this;
  663. }
  664. else
  665. {
  666. *ppv = NULL;
  667. return E_NOINTERFACE;
  668. }
  669. AddRef();
  670. return NOERROR;
  671. }
  672. HRESULT
  673. CNetAddress::AllocateNetAddressObject(
  674. CNetAddress ** ppNetAddress
  675. )
  676. {
  677. CNetAddress FAR * pNetAddress = NULL;
  678. CDispatchMgr FAR * pDispMgr = NULL;
  679. HRESULT hr = S_OK;
  680. pNetAddress = new CNetAddress();
  681. if (pNetAddress == NULL) {
  682. hr = E_OUTOFMEMORY;
  683. }
  684. BAIL_ON_FAILURE(hr);
  685. pDispMgr = new CDispatchMgr;
  686. if (pDispMgr == NULL) {
  687. hr = E_OUTOFMEMORY;
  688. }
  689. BAIL_ON_FAILURE(hr);
  690. hr = LoadTypeInfoEntry(
  691. pDispMgr,
  692. LIBID_ADs,
  693. IID_IADsNetAddress,
  694. (IADsNetAddress *)pNetAddress,
  695. DISPID_REGULAR
  696. );
  697. BAIL_ON_FAILURE(hr);
  698. pNetAddress->_pDispMgr = pDispMgr;
  699. *ppNetAddress = pNetAddress;
  700. RRETURN(hr);
  701. error:
  702. delete pDispMgr;
  703. RRETURN(hr);
  704. }
  705. STDMETHODIMP
  706. CNetAddress::get_AddressType(THIS_ long FAR * retval)
  707. {
  708. *retval = _dwAddressType;
  709. RRETURN(S_OK);
  710. }
  711. STDMETHODIMP
  712. CNetAddress::put_AddressType(THIS_ long lnAddressType)
  713. {
  714. _dwAddressType = lnAddressType;
  715. RRETURN(S_OK);
  716. }
  717. STDMETHODIMP
  718. CNetAddress::get_Address(THIS_ VARIANT FAR * pVarDestObject)
  719. {
  720. HRESULT hr = S_OK;
  721. SAFEARRAY *aList = NULL;
  722. SAFEARRAYBOUND aBound;
  723. CHAR HUGEP *pArray = NULL;
  724. aBound.lLbound = 0;
  725. aBound.cElements = _dwAddressLength;
  726. aList = SafeArrayCreate( VT_UI1, 1, &aBound );
  727. if ( aList == NULL ) {
  728. hr = E_OUTOFMEMORY;
  729. BAIL_ON_FAILURE(hr);
  730. }
  731. hr = SafeArrayAccessData( aList, (void HUGEP * FAR *) &pArray );
  732. BAIL_ON_FAILURE(hr);
  733. memcpy( pArray,
  734. _pbAddress,
  735. aBound.cElements );
  736. SafeArrayUnaccessData( aList );
  737. V_VT(pVarDestObject) = VT_ARRAY | VT_UI1;
  738. V_ARRAY(pVarDestObject) = aList;
  739. RRETURN(hr);
  740. error:
  741. if ( aList ) {
  742. SafeArrayDestroy( aList );
  743. }
  744. RRETURN(hr);
  745. }
  746. STDMETHODIMP
  747. CNetAddress::put_Address(THIS_ VARIANT VarSrcObject)
  748. {
  749. HRESULT hr = S_OK;
  750. LONG dwSLBound = 0;
  751. LONG dwSUBound = 0;
  752. CHAR HUGEP *pArray = NULL;
  753. VARIANT *pVarSrcObject = &VarSrcObject;
  754. if (_pbAddress) {
  755. FreeADsMem(_pbAddress);
  756. }
  757. if( pVarSrcObject->vt != (VT_ARRAY | VT_UI1)) {
  758. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  759. }
  760. hr = SafeArrayGetLBound(V_ARRAY(pVarSrcObject),
  761. 1,
  762. (long FAR *) &dwSLBound );
  763. BAIL_ON_FAILURE(hr);
  764. hr = SafeArrayGetUBound(V_ARRAY(pVarSrcObject),
  765. 1,
  766. (long FAR *) &dwSUBound );
  767. BAIL_ON_FAILURE(hr);
  768. _pbAddress =
  769. (BYTE*) AllocADsMem( dwSUBound - dwSLBound + 1);
  770. if ( _pbAddress == NULL)
  771. {
  772. hr = E_OUTOFMEMORY;
  773. BAIL_ON_FAILURE(hr);
  774. }
  775. _dwAddressLength = dwSUBound - dwSLBound + 1;
  776. hr = SafeArrayAccessData( V_ARRAY(pVarSrcObject),
  777. (void HUGEP * FAR *) &pArray );
  778. BAIL_ON_FAILURE(hr);
  779. memcpy( _pbAddress,
  780. pArray,
  781. _dwAddressLength );
  782. SafeArrayUnaccessData( V_ARRAY(pVarSrcObject) );
  783. error:
  784. RRETURN(hr);
  785. }
  786. DEFINE_IDispatch_Implementation(COctetList)
  787. COctetList::COctetList():
  788. _pDispMgr(NULL),
  789. _rgOctetList(NULL)
  790. {
  791. ENLIST_TRACKING(COctetList);
  792. }
  793. HRESULT
  794. COctetList::CreateOctetList(
  795. REFIID riid,
  796. void **ppvObj
  797. )
  798. {
  799. COctetList FAR * pOctetList = NULL;
  800. HRESULT hr = S_OK;
  801. hr = AllocateOctetListObject(&pOctetList);
  802. BAIL_ON_FAILURE(hr);
  803. hr = pOctetList->QueryInterface(riid, ppvObj);
  804. BAIL_ON_FAILURE(hr);
  805. pOctetList->Release();
  806. RRETURN(hr);
  807. error:
  808. delete pOctetList;
  809. RRETURN(hr);
  810. }
  811. COctetList::~COctetList( )
  812. {
  813. delete _pDispMgr;
  814. if (_rgOctetList) {
  815. long i;
  816. for (i=0;i<(long)_dwNumElement;i++) {
  817. if (_rgOctetList[i]) {
  818. FreeADsMem(_rgOctetList[i]);
  819. }
  820. }
  821. FreeADsMem(_rgOctetList);
  822. }
  823. }
  824. STDMETHODIMP
  825. COctetList::QueryInterface(
  826. REFIID iid,
  827. LPVOID FAR* ppv
  828. )
  829. {
  830. if (IsEqualIID(iid, IID_IUnknown))
  831. {
  832. *ppv = (IADsOctetList FAR *) this;
  833. }
  834. else if (IsEqualIID(iid, IID_IADsOctetList))
  835. {
  836. *ppv = (IADsOctetList FAR *) this;
  837. }
  838. else if (IsEqualIID(iid, IID_IDispatch))
  839. {
  840. *ppv = (IADsOctetList FAR *) this;
  841. }
  842. else
  843. {
  844. *ppv = NULL;
  845. return E_NOINTERFACE;
  846. }
  847. AddRef();
  848. return NOERROR;
  849. }
  850. HRESULT
  851. COctetList::AllocateOctetListObject(
  852. COctetList ** ppOctetList
  853. )
  854. {
  855. COctetList FAR * pOctetList = NULL;
  856. CDispatchMgr FAR * pDispMgr = NULL;
  857. HRESULT hr = S_OK;
  858. pOctetList = new COctetList();
  859. if (pOctetList == NULL) {
  860. hr = E_OUTOFMEMORY;
  861. }
  862. BAIL_ON_FAILURE(hr);
  863. pDispMgr = new CDispatchMgr;
  864. if (pDispMgr == NULL) {
  865. hr = E_OUTOFMEMORY;
  866. }
  867. BAIL_ON_FAILURE(hr);
  868. hr = LoadTypeInfoEntry(
  869. pDispMgr,
  870. LIBID_ADs,
  871. IID_IADsOctetList,
  872. (IADsOctetList *)pOctetList,
  873. DISPID_REGULAR
  874. );
  875. BAIL_ON_FAILURE(hr);
  876. pOctetList->_pDispMgr = pDispMgr;
  877. *ppOctetList = pOctetList;
  878. RRETURN(hr);
  879. error:
  880. delete pDispMgr;
  881. RRETURN(hr);
  882. }
  883. STDMETHODIMP
  884. COctetList::get_OctetList(THIS_ VARIANT FAR * pVarDestObject)
  885. {
  886. HRESULT hr = S_OK;
  887. hr = ConvertBinaryArrayToSafeVariantArray(
  888. _rgOctetList,
  889. _dwNumElement,
  890. pVarDestObject);
  891. RRETURN(hr);
  892. }
  893. STDMETHODIMP
  894. COctetList::put_OctetList(THIS_ VARIANT VarSrcObject)
  895. {
  896. HRESULT hr = S_OK;
  897. if (_rgOctetList) {
  898. long i;
  899. for (i=0;i<(long)_dwNumElement;i++) {
  900. if (_rgOctetList[i]) {
  901. FreeADsMem(_rgOctetList[i]);
  902. }
  903. }
  904. FreeADsMem(_rgOctetList);
  905. }
  906. hr = ConvertSafeVariantArrayToBinaryArray(
  907. VarSrcObject,
  908. &_rgOctetList,
  909. &_dwNumElement);
  910. RRETURN(hr);
  911. }
  912. DEFINE_IDispatch_Implementation(CEmail)
  913. CEmail::CEmail():
  914. _pDispMgr(NULL),
  915. _szAddress(NULL),
  916. _dwType(0)
  917. {
  918. ENLIST_TRACKING(CEmail);
  919. }
  920. HRESULT
  921. CEmail::CreateEmail(
  922. REFIID riid,
  923. void **ppvObj
  924. )
  925. {
  926. CEmail FAR * pEmail = NULL;
  927. HRESULT hr = S_OK;
  928. hr = AllocateEmailObject(&pEmail);
  929. BAIL_ON_FAILURE(hr);
  930. hr = pEmail->QueryInterface(riid, ppvObj);
  931. BAIL_ON_FAILURE(hr);
  932. pEmail->Release();
  933. RRETURN(hr);
  934. error:
  935. delete pEmail;
  936. RRETURN(hr);
  937. }
  938. CEmail::~CEmail( )
  939. {
  940. delete _pDispMgr;
  941. if (_szAddress) {
  942. FreeADsStr(_szAddress);
  943. }
  944. }
  945. STDMETHODIMP
  946. CEmail::QueryInterface(
  947. REFIID iid,
  948. LPVOID FAR* ppv
  949. )
  950. {
  951. if (IsEqualIID(iid, IID_IUnknown))
  952. {
  953. *ppv = (IADsEmail FAR *) this;
  954. }
  955. else if (IsEqualIID(iid, IID_IADsEmail))
  956. {
  957. *ppv = (IADsEmail FAR *) this;
  958. }
  959. else if (IsEqualIID(iid, IID_IDispatch))
  960. {
  961. *ppv = (IADsEmail FAR *) this;
  962. }
  963. else
  964. {
  965. *ppv = NULL;
  966. return E_NOINTERFACE;
  967. }
  968. AddRef();
  969. return NOERROR;
  970. }
  971. HRESULT
  972. CEmail::AllocateEmailObject(
  973. CEmail ** ppEmail
  974. )
  975. {
  976. CEmail FAR * pEmail = NULL;
  977. CDispatchMgr FAR * pDispMgr = NULL;
  978. HRESULT hr = S_OK;
  979. pEmail = new CEmail();
  980. if (pEmail == NULL) {
  981. hr = E_OUTOFMEMORY;
  982. }
  983. BAIL_ON_FAILURE(hr);
  984. pDispMgr = new CDispatchMgr;
  985. if (pDispMgr == NULL) {
  986. hr = E_OUTOFMEMORY;
  987. }
  988. BAIL_ON_FAILURE(hr);
  989. hr = LoadTypeInfoEntry(
  990. pDispMgr,
  991. LIBID_ADs,
  992. IID_IADsEmail,
  993. (IADsEmail *)pEmail,
  994. DISPID_REGULAR
  995. );
  996. BAIL_ON_FAILURE(hr);
  997. pEmail->_pDispMgr = pDispMgr;
  998. *ppEmail = pEmail;
  999. RRETURN(hr);
  1000. error:
  1001. delete pDispMgr;
  1002. RRETURN(hr);
  1003. }
  1004. STDMETHODIMP
  1005. CEmail::get_Address(THIS_ BSTR FAR * retval)
  1006. {
  1007. HRESULT hr = S_OK;
  1008. hr = ADsAllocString(_szAddress, retval);
  1009. RRETURN(hr);
  1010. }
  1011. STDMETHODIMP
  1012. CEmail::put_Address(THIS_ BSTR bstrAddress)
  1013. {
  1014. if (!bstrAddress) {
  1015. RRETURN(E_FAIL);
  1016. }
  1017. if (_szAddress) {
  1018. FreeADsStr(_szAddress);
  1019. }
  1020. _szAddress = AllocADsStr(bstrAddress);
  1021. if (!_szAddress) {
  1022. RRETURN(E_OUTOFMEMORY);
  1023. }
  1024. RRETURN(S_OK);
  1025. }
  1026. STDMETHODIMP
  1027. CEmail::get_Type(THIS_ long FAR * retval)
  1028. {
  1029. *retval = _dwType;
  1030. RRETURN(S_OK);
  1031. }
  1032. STDMETHODIMP
  1033. CEmail::put_Type(THIS_ long lnType)
  1034. {
  1035. _dwType = lnType;
  1036. RRETURN(S_OK);
  1037. }
  1038. DEFINE_IDispatch_Implementation(CPath)
  1039. CPath::CPath():
  1040. _pDispMgr(NULL),
  1041. _dwType(0),
  1042. _lpVolumeName(NULL),
  1043. _lpPath(NULL)
  1044. {
  1045. ENLIST_TRACKING(CPath);
  1046. }
  1047. HRESULT
  1048. CPath::CreatePath(
  1049. REFIID riid,
  1050. void **ppvObj
  1051. )
  1052. {
  1053. CPath FAR * pPath = NULL;
  1054. HRESULT hr = S_OK;
  1055. hr = AllocatePathObject(&pPath);
  1056. BAIL_ON_FAILURE(hr);
  1057. hr = pPath->QueryInterface(riid, ppvObj);
  1058. BAIL_ON_FAILURE(hr);
  1059. pPath->Release();
  1060. RRETURN(hr);
  1061. error:
  1062. delete pPath;
  1063. RRETURN(hr);
  1064. }
  1065. CPath::~CPath( )
  1066. {
  1067. delete _pDispMgr;
  1068. if (_lpVolumeName) {
  1069. FreeADsStr(_lpVolumeName);
  1070. }
  1071. if (_lpPath) {
  1072. FreeADsStr(_lpPath);
  1073. }
  1074. }
  1075. STDMETHODIMP
  1076. CPath::QueryInterface(
  1077. REFIID iid,
  1078. LPVOID FAR* ppv
  1079. )
  1080. {
  1081. if (IsEqualIID(iid, IID_IUnknown))
  1082. {
  1083. *ppv = (IADsPath FAR *) this;
  1084. }
  1085. else if (IsEqualIID(iid, IID_IADsPath))
  1086. {
  1087. *ppv = (IADsPath FAR *) this;
  1088. }
  1089. else if (IsEqualIID(iid, IID_IDispatch))
  1090. {
  1091. *ppv = (IADsPath FAR *) this;
  1092. }
  1093. else
  1094. {
  1095. *ppv = NULL;
  1096. return E_NOINTERFACE;
  1097. }
  1098. AddRef();
  1099. return NOERROR;
  1100. }
  1101. HRESULT
  1102. CPath::AllocatePathObject(
  1103. CPath ** ppPath
  1104. )
  1105. {
  1106. CPath FAR * pPath = NULL;
  1107. CDispatchMgr FAR * pDispMgr = NULL;
  1108. HRESULT hr = S_OK;
  1109. pPath = new CPath();
  1110. if (pPath == NULL) {
  1111. hr = E_OUTOFMEMORY;
  1112. }
  1113. BAIL_ON_FAILURE(hr);
  1114. pDispMgr = new CDispatchMgr;
  1115. if (pDispMgr == NULL) {
  1116. hr = E_OUTOFMEMORY;
  1117. }
  1118. BAIL_ON_FAILURE(hr);
  1119. hr = LoadTypeInfoEntry(
  1120. pDispMgr,
  1121. LIBID_ADs,
  1122. IID_IADsPath,
  1123. (IADsPath *)pPath,
  1124. DISPID_REGULAR
  1125. );
  1126. BAIL_ON_FAILURE(hr);
  1127. pPath->_pDispMgr = pDispMgr;
  1128. *ppPath = pPath;
  1129. RRETURN(hr);
  1130. error:
  1131. delete pDispMgr;
  1132. RRETURN(hr);
  1133. }
  1134. STDMETHODIMP
  1135. CPath::get_Type(THIS_ long FAR * retval)
  1136. {
  1137. *retval = _dwType;
  1138. RRETURN(S_OK);
  1139. }
  1140. STDMETHODIMP
  1141. CPath::put_Type(THIS_ long lnType)
  1142. {
  1143. _dwType = lnType;
  1144. RRETURN(S_OK);
  1145. }
  1146. STDMETHODIMP
  1147. CPath::get_VolumeName(THIS_ BSTR FAR * retval)
  1148. {
  1149. HRESULT hr = S_OK;
  1150. hr = ADsAllocString(_lpVolumeName, retval);
  1151. RRETURN(hr);
  1152. }
  1153. STDMETHODIMP
  1154. CPath::put_VolumeName(THIS_ BSTR bstrVolumeName)
  1155. {
  1156. if (!bstrVolumeName) {
  1157. RRETURN(E_FAIL);
  1158. }
  1159. if (_lpVolumeName) {
  1160. FreeADsStr(_lpVolumeName);
  1161. }
  1162. _lpVolumeName= AllocADsStr(bstrVolumeName);
  1163. if (!_lpVolumeName) {
  1164. RRETURN(E_OUTOFMEMORY);
  1165. }
  1166. RRETURN(S_OK);
  1167. }
  1168. STDMETHODIMP
  1169. CPath::get_Path(THIS_ BSTR FAR * retval)
  1170. {
  1171. HRESULT hr = S_OK;
  1172. hr = ADsAllocString(_lpPath, retval);
  1173. RRETURN(hr);
  1174. }
  1175. STDMETHODIMP
  1176. CPath::put_Path(THIS_ BSTR bstrPath)
  1177. {
  1178. if (!bstrPath) {
  1179. RRETURN(E_FAIL);
  1180. }
  1181. if (_lpPath) {
  1182. FreeADsStr(_lpPath);
  1183. }
  1184. _lpPath= AllocADsStr(bstrPath);
  1185. if (!_lpPath) {
  1186. RRETURN(E_OUTOFMEMORY);
  1187. }
  1188. RRETURN(S_OK);
  1189. }
  1190. //////////////////////////////////////////////////////////////////////////
  1191. DEFINE_IDispatch_Implementation(CReplicaPointer)
  1192. CReplicaPointer::CReplicaPointer():
  1193. _pDispMgr(NULL),
  1194. _lpServerName(NULL),
  1195. _dwReplicaType(0),
  1196. _dwReplicaNumber(0),
  1197. _dwCount(0)
  1198. {
  1199. ENLIST_TRACKING(CReplicaPointer);
  1200. _ReplicaAddressHints.AddressType = 0;
  1201. _ReplicaAddressHints.AddressLength = 0;
  1202. _ReplicaAddressHints.Address = NULL;
  1203. }
  1204. HRESULT
  1205. CReplicaPointer::CreateReplicaPointer(
  1206. REFIID riid,
  1207. void **ppvObj
  1208. )
  1209. {
  1210. CReplicaPointer FAR * pReplicaPointer = NULL;
  1211. HRESULT hr = S_OK;
  1212. hr = AllocateReplicaPointerObject(&pReplicaPointer);
  1213. BAIL_ON_FAILURE(hr);
  1214. hr = pReplicaPointer->QueryInterface(riid, ppvObj);
  1215. BAIL_ON_FAILURE(hr);
  1216. pReplicaPointer->Release();
  1217. RRETURN(hr);
  1218. error:
  1219. delete pReplicaPointer;
  1220. RRETURN(hr);
  1221. }
  1222. CReplicaPointer::~CReplicaPointer( )
  1223. {
  1224. delete _pDispMgr;
  1225. if (_lpServerName) {
  1226. FreeADsStr(_lpServerName);
  1227. }
  1228. if (_ReplicaAddressHints.Address) {
  1229. FreeADsMem(_ReplicaAddressHints.Address);
  1230. }
  1231. }
  1232. STDMETHODIMP
  1233. CReplicaPointer::QueryInterface(
  1234. REFIID iid,
  1235. LPVOID FAR* ppv
  1236. )
  1237. {
  1238. if (IsEqualIID(iid, IID_IUnknown))
  1239. {
  1240. *ppv = (IADsReplicaPointer FAR *) this;
  1241. }
  1242. else if (IsEqualIID(iid, IID_IADsReplicaPointer))
  1243. {
  1244. *ppv = (IADsReplicaPointer FAR *) this;
  1245. }
  1246. else if (IsEqualIID(iid, IID_IDispatch))
  1247. {
  1248. *ppv = (IADsReplicaPointer FAR *) this;
  1249. }
  1250. else
  1251. {
  1252. *ppv = NULL;
  1253. return E_NOINTERFACE;
  1254. }
  1255. AddRef();
  1256. return NOERROR;
  1257. }
  1258. HRESULT
  1259. CReplicaPointer::AllocateReplicaPointerObject(
  1260. CReplicaPointer ** ppReplicaPointer
  1261. )
  1262. {
  1263. CReplicaPointer FAR * pReplicaPointer = NULL;
  1264. CDispatchMgr FAR * pDispMgr = NULL;
  1265. HRESULT hr = S_OK;
  1266. pReplicaPointer = new CReplicaPointer();
  1267. if (pReplicaPointer == NULL) {
  1268. hr = E_OUTOFMEMORY;
  1269. }
  1270. BAIL_ON_FAILURE(hr);
  1271. pDispMgr = new CDispatchMgr;
  1272. if (pDispMgr == NULL) {
  1273. hr = E_OUTOFMEMORY;
  1274. }
  1275. BAIL_ON_FAILURE(hr);
  1276. hr = LoadTypeInfoEntry(
  1277. pDispMgr,
  1278. LIBID_ADs,
  1279. IID_IADsReplicaPointer,
  1280. (IADsReplicaPointer *)pReplicaPointer,
  1281. DISPID_REGULAR
  1282. );
  1283. BAIL_ON_FAILURE(hr);
  1284. pReplicaPointer->_pDispMgr = pDispMgr;
  1285. *ppReplicaPointer = pReplicaPointer;
  1286. RRETURN(hr);
  1287. error:
  1288. delete pDispMgr;
  1289. RRETURN(hr);
  1290. }
  1291. STDMETHODIMP
  1292. CReplicaPointer::get_ReplicaType(THIS_ long FAR * retval)
  1293. {
  1294. *retval = _dwReplicaType;
  1295. RRETURN(S_OK);
  1296. }
  1297. STDMETHODIMP
  1298. CReplicaPointer::put_ReplicaType(THIS_ long lnReplicaType)
  1299. {
  1300. _dwReplicaType = lnReplicaType;
  1301. RRETURN(S_OK);
  1302. }
  1303. STDMETHODIMP
  1304. CReplicaPointer::get_ReplicaNumber(THIS_ long FAR * retval)
  1305. {
  1306. *retval = _dwReplicaNumber;
  1307. RRETURN(S_OK);
  1308. }
  1309. STDMETHODIMP
  1310. CReplicaPointer::put_ReplicaNumber(THIS_ long lnReplicaNumber)
  1311. {
  1312. _dwReplicaNumber = lnReplicaNumber;
  1313. RRETURN(S_OK);
  1314. }
  1315. STDMETHODIMP
  1316. CReplicaPointer::get_Count(THIS_ long FAR * retval)
  1317. {
  1318. *retval = _dwCount;
  1319. RRETURN(S_OK);
  1320. }
  1321. STDMETHODIMP
  1322. CReplicaPointer::put_Count(THIS_ long lnCount)
  1323. {
  1324. _dwCount = lnCount;
  1325. RRETURN(S_OK);
  1326. }
  1327. STDMETHODIMP
  1328. CReplicaPointer::get_ServerName(THIS_ BSTR FAR * retval)
  1329. {
  1330. HRESULT hr = S_OK;
  1331. hr = ADsAllocString(_lpServerName, retval);
  1332. RRETURN(hr);
  1333. }
  1334. STDMETHODIMP
  1335. CReplicaPointer::put_ServerName(THIS_ BSTR bstrServerName)
  1336. {
  1337. if (!bstrServerName) {
  1338. RRETURN(E_FAIL);
  1339. }
  1340. if (_lpServerName) {
  1341. FreeADsStr(_lpServerName);
  1342. }
  1343. _lpServerName= AllocADsStr(bstrServerName);
  1344. if (!_lpServerName) {
  1345. RRETURN(E_OUTOFMEMORY);
  1346. }
  1347. RRETURN(S_OK);
  1348. }
  1349. STDMETHODIMP
  1350. CReplicaPointer::get_ReplicaAddressHints(THIS_ VARIANT* pValAddress)
  1351. {
  1352. HRESULT hr = S_OK;
  1353. NDSOBJECT object;
  1354. memcpy(&object.NdsValue.value_12,
  1355. &_ReplicaAddressHints,
  1356. sizeof(NDS_ASN1_TYPE_12));
  1357. hr = NdsTypeToVarTypeCopyNDSSynId12(
  1358. &object,
  1359. pValAddress
  1360. );
  1361. RRETURN(hr);
  1362. }
  1363. STDMETHODIMP
  1364. CReplicaPointer::put_ReplicaAddressHints(THIS_ VARIANT ValAddress)
  1365. {
  1366. HRESULT hr;
  1367. NDSOBJECT object;
  1368. if (_ReplicaAddressHints.Address) {
  1369. FreeADsMem(_ReplicaAddressHints.Address);
  1370. }
  1371. hr = VarTypeToNdsTypeCopyNDSSynId12(
  1372. &ValAddress,
  1373. &object
  1374. );
  1375. BAIL_ON_FAILURE(hr);
  1376. memcpy(&_ReplicaAddressHints,
  1377. &object.NdsValue.value_12,
  1378. sizeof(NDS_ASN1_TYPE_12));
  1379. error:
  1380. RRETURN(hr);
  1381. }
  1382. DEFINE_IDispatch_Implementation(CTimestamp)
  1383. CTimestamp::CTimestamp():
  1384. _pDispMgr(NULL),
  1385. _dwWholeSeconds(0),
  1386. _dwEventID(0)
  1387. {
  1388. ENLIST_TRACKING(CTimestamp);
  1389. }
  1390. HRESULT
  1391. CTimestamp::CreateTimestamp(
  1392. REFIID riid,
  1393. void **ppvObj
  1394. )
  1395. {
  1396. CTimestamp FAR * pTime = NULL;
  1397. HRESULT hr = S_OK;
  1398. hr = AllocateTimestampObject(&pTime);
  1399. BAIL_ON_FAILURE(hr);
  1400. hr = pTime->QueryInterface(riid, ppvObj);
  1401. BAIL_ON_FAILURE(hr);
  1402. pTime->Release();
  1403. RRETURN(hr);
  1404. error:
  1405. delete pTime;
  1406. RRETURN(hr);
  1407. }
  1408. CTimestamp::~CTimestamp( )
  1409. {
  1410. delete _pDispMgr;
  1411. }
  1412. STDMETHODIMP
  1413. CTimestamp::QueryInterface(
  1414. REFIID iid,
  1415. LPVOID FAR* ppv
  1416. )
  1417. {
  1418. if (IsEqualIID(iid, IID_IUnknown))
  1419. {
  1420. *ppv = (IADsTimestamp FAR *) this;
  1421. }
  1422. else if (IsEqualIID(iid, IID_IADsTimestamp))
  1423. {
  1424. *ppv = (IADsTimestamp FAR *) this;
  1425. }
  1426. else if (IsEqualIID(iid, IID_IDispatch))
  1427. {
  1428. *ppv = (IADsTimestamp FAR *) this;
  1429. }
  1430. else
  1431. {
  1432. *ppv = NULL;
  1433. return E_NOINTERFACE;
  1434. }
  1435. AddRef();
  1436. return NOERROR;
  1437. }
  1438. HRESULT
  1439. CTimestamp::AllocateTimestampObject(
  1440. CTimestamp ** ppTime
  1441. )
  1442. {
  1443. CTimestamp FAR * pTime = NULL;
  1444. CDispatchMgr FAR * pDispMgr = NULL;
  1445. HRESULT hr = S_OK;
  1446. pTime = new CTimestamp();
  1447. if (pTime == NULL) {
  1448. hr = E_OUTOFMEMORY;
  1449. }
  1450. BAIL_ON_FAILURE(hr);
  1451. pDispMgr = new CDispatchMgr;
  1452. if (pDispMgr == NULL) {
  1453. hr = E_OUTOFMEMORY;
  1454. }
  1455. BAIL_ON_FAILURE(hr);
  1456. hr = LoadTypeInfoEntry(
  1457. pDispMgr,
  1458. LIBID_ADs,
  1459. IID_IADsTimestamp,
  1460. (IADsTimestamp *)pTime,
  1461. DISPID_REGULAR
  1462. );
  1463. BAIL_ON_FAILURE(hr);
  1464. pTime->_pDispMgr = pDispMgr;
  1465. *ppTime = pTime;
  1466. RRETURN(hr);
  1467. error:
  1468. delete pDispMgr;
  1469. RRETURN(hr);
  1470. }
  1471. STDMETHODIMP
  1472. CTimestamp::get_WholeSeconds(THIS_ long FAR * retval)
  1473. {
  1474. *retval = _dwWholeSeconds;
  1475. RRETURN(S_OK);
  1476. }
  1477. STDMETHODIMP
  1478. CTimestamp::put_WholeSeconds(THIS_ long lnWholeSeconds)
  1479. {
  1480. _dwWholeSeconds = lnWholeSeconds;
  1481. RRETURN(S_OK);
  1482. }
  1483. STDMETHODIMP
  1484. CTimestamp::get_EventID(THIS_ long FAR * retval)
  1485. {
  1486. *retval = _dwEventID;
  1487. RRETURN(S_OK);
  1488. }
  1489. STDMETHODIMP
  1490. CTimestamp::put_EventID(THIS_ long lnEventID)
  1491. {
  1492. _dwEventID = lnEventID;
  1493. RRETURN(S_OK);
  1494. }
  1495. DEFINE_IDispatch_Implementation(CPostalAddress)
  1496. CPostalAddress::CPostalAddress():
  1497. _pDispMgr(NULL),
  1498. _rgszPostalAddress(NULL),
  1499. _dwNumElement(0)
  1500. {
  1501. ENLIST_TRACKING(CPostalAddress);
  1502. }
  1503. HRESULT
  1504. CPostalAddress::CreatePostalAddress(
  1505. REFIID riid,
  1506. void **ppvObj
  1507. )
  1508. {
  1509. CPostalAddress FAR * pPostalAddress = NULL;
  1510. HRESULT hr = S_OK;
  1511. hr = AllocatePostalAddressObject(&pPostalAddress);
  1512. BAIL_ON_FAILURE(hr);
  1513. hr = pPostalAddress->QueryInterface(riid, ppvObj);
  1514. BAIL_ON_FAILURE(hr);
  1515. pPostalAddress->Release();
  1516. RRETURN(hr);
  1517. error:
  1518. delete pPostalAddress;
  1519. RRETURN(hr);
  1520. }
  1521. CPostalAddress::~CPostalAddress( )
  1522. {
  1523. delete _pDispMgr;
  1524. if (_rgszPostalAddress) {
  1525. long i;
  1526. for (i=0;i<(long)_dwNumElement;i++) {
  1527. if (_rgszPostalAddress[i]) {
  1528. FreeADsStr(_rgszPostalAddress[i]);
  1529. }
  1530. }
  1531. FreeADsMem(_rgszPostalAddress);
  1532. }
  1533. }
  1534. STDMETHODIMP
  1535. CPostalAddress::QueryInterface(
  1536. REFIID iid,
  1537. LPVOID FAR* ppv
  1538. )
  1539. {
  1540. if (IsEqualIID(iid, IID_IUnknown))
  1541. {
  1542. *ppv = (IADsPostalAddress FAR *) this;
  1543. }
  1544. else if (IsEqualIID(iid, IID_IADsPostalAddress))
  1545. {
  1546. *ppv = (IADsPostalAddress FAR *) this;
  1547. }
  1548. else if (IsEqualIID(iid, IID_IDispatch))
  1549. {
  1550. *ppv = (IADsPostalAddress FAR *) this;
  1551. }
  1552. else
  1553. {
  1554. *ppv = NULL;
  1555. return E_NOINTERFACE;
  1556. }
  1557. AddRef();
  1558. return NOERROR;
  1559. }
  1560. HRESULT
  1561. CPostalAddress::AllocatePostalAddressObject(
  1562. CPostalAddress ** ppPostalAddress
  1563. )
  1564. {
  1565. CPostalAddress FAR * pPostalAddress = NULL;
  1566. CDispatchMgr FAR * pDispMgr = NULL;
  1567. HRESULT hr = S_OK;
  1568. pPostalAddress = new CPostalAddress();
  1569. if (pPostalAddress == NULL) {
  1570. hr = E_OUTOFMEMORY;
  1571. }
  1572. BAIL_ON_FAILURE(hr);
  1573. pDispMgr = new CDispatchMgr;
  1574. if (pDispMgr == NULL) {
  1575. hr = E_OUTOFMEMORY;
  1576. }
  1577. BAIL_ON_FAILURE(hr);
  1578. hr = LoadTypeInfoEntry(
  1579. pDispMgr,
  1580. LIBID_ADs,
  1581. IID_IADsPostalAddress,
  1582. (IADsPostalAddress *)pPostalAddress,
  1583. DISPID_REGULAR
  1584. );
  1585. BAIL_ON_FAILURE(hr);
  1586. pPostalAddress->_pDispMgr = pDispMgr;
  1587. *ppPostalAddress = pPostalAddress;
  1588. RRETURN(hr);
  1589. error:
  1590. delete pDispMgr;
  1591. RRETURN(hr);
  1592. }
  1593. STDMETHODIMP
  1594. CPostalAddress::get_PostalAddress(THIS_ VARIANT FAR * pVarDestObject)
  1595. {
  1596. HRESULT hr = S_OK;
  1597. hr = ConvertStringArrayToSafeBstrArray(
  1598. _rgszPostalAddress,
  1599. _dwNumElement,
  1600. pVarDestObject);
  1601. RRETURN(hr);
  1602. }
  1603. STDMETHODIMP
  1604. CPostalAddress::put_PostalAddress(THIS_ VARIANT VarSrcObject)
  1605. {
  1606. HRESULT hr = S_OK;
  1607. SAFEARRAY * pArray = NULL;
  1608. if (_rgszPostalAddress) {
  1609. long i;
  1610. for (i=0;i<(long)_dwNumElement;i++) {
  1611. if (_rgszPostalAddress[i]) {
  1612. FreeADsStr(_rgszPostalAddress[i]);
  1613. }
  1614. }
  1615. FreeADsMem(_rgszPostalAddress);
  1616. }
  1617. //
  1618. // Make sure it has 6 elements
  1619. //
  1620. if(!((V_VT(&VarSrcObject) & VT_VARIANT) && V_ISARRAY(&VarSrcObject)))
  1621. RRETURN(E_FAIL);
  1622. if (V_VT(&VarSrcObject) & VT_BYREF)
  1623. pArray = *(V_ARRAYREF(&VarSrcObject));
  1624. else
  1625. pArray = V_ARRAY(&VarSrcObject);
  1626. if ((pArray->rgsabound[0].cElements > 6) || (pArray->rgsabound[0].cElements <= 0)){
  1627. RRETURN(E_FAIL);
  1628. }
  1629. hr = ConvertSafeBstrArrayToStringArray(
  1630. VarSrcObject,
  1631. &_rgszPostalAddress,
  1632. &_dwNumElement);
  1633. RRETURN(hr);
  1634. }
  1635. //////////////////////////////////////////////////////////////////////////
  1636. DEFINE_IDispatch_Implementation(CBackLink)
  1637. CBackLink::CBackLink():
  1638. _pDispMgr(NULL),
  1639. _lpObjectName(NULL),
  1640. _dwRemoteID(0)
  1641. {
  1642. ENLIST_TRACKING(CBackLink);
  1643. }
  1644. HRESULT
  1645. CBackLink::CreateBackLink(
  1646. REFIID riid,
  1647. void **ppvObj
  1648. )
  1649. {
  1650. CBackLink FAR * pBackLink = NULL;
  1651. HRESULT hr = S_OK;
  1652. hr = AllocateBackLinkObject(&pBackLink);
  1653. BAIL_ON_FAILURE(hr);
  1654. hr = pBackLink->QueryInterface(riid, ppvObj);
  1655. BAIL_ON_FAILURE(hr);
  1656. pBackLink->Release();
  1657. RRETURN(hr);
  1658. error:
  1659. delete pBackLink;
  1660. RRETURN(hr);
  1661. }
  1662. CBackLink::~CBackLink( )
  1663. {
  1664. delete _pDispMgr;
  1665. if (_lpObjectName) {
  1666. FreeADsStr(_lpObjectName);
  1667. }
  1668. }
  1669. STDMETHODIMP
  1670. CBackLink::QueryInterface(
  1671. REFIID iid,
  1672. LPVOID FAR* ppv
  1673. )
  1674. {
  1675. if (IsEqualIID(iid, IID_IUnknown))
  1676. {
  1677. *ppv = (IADsBackLink FAR *) this;
  1678. }
  1679. else if (IsEqualIID(iid, IID_IADsBackLink))
  1680. {
  1681. *ppv = (IADsBackLink FAR *) this;
  1682. }
  1683. else if (IsEqualIID(iid, IID_IDispatch))
  1684. {
  1685. *ppv = (IADsBackLink FAR *) this;
  1686. }
  1687. else
  1688. {
  1689. *ppv = NULL;
  1690. return E_NOINTERFACE;
  1691. }
  1692. AddRef();
  1693. return NOERROR;
  1694. }
  1695. HRESULT
  1696. CBackLink::AllocateBackLinkObject(
  1697. CBackLink ** ppBackLink
  1698. )
  1699. {
  1700. CBackLink FAR * pBackLink = NULL;
  1701. CDispatchMgr FAR * pDispMgr = NULL;
  1702. HRESULT hr = S_OK;
  1703. pBackLink = new CBackLink();
  1704. if (pBackLink == NULL) {
  1705. hr = E_OUTOFMEMORY;
  1706. }
  1707. BAIL_ON_FAILURE(hr);
  1708. pDispMgr = new CDispatchMgr;
  1709. if (pDispMgr == NULL) {
  1710. hr = E_OUTOFMEMORY;
  1711. }
  1712. BAIL_ON_FAILURE(hr);
  1713. hr = LoadTypeInfoEntry(
  1714. pDispMgr,
  1715. LIBID_ADs,
  1716. IID_IADsBackLink,
  1717. (IADsBackLink *)pBackLink,
  1718. DISPID_REGULAR
  1719. );
  1720. BAIL_ON_FAILURE(hr);
  1721. pBackLink->_pDispMgr = pDispMgr;
  1722. *ppBackLink = pBackLink;
  1723. RRETURN(hr);
  1724. error:
  1725. delete pDispMgr;
  1726. RRETURN(hr);
  1727. }
  1728. STDMETHODIMP
  1729. CBackLink::get_RemoteID(THIS_ long FAR * retval)
  1730. {
  1731. *retval = _dwRemoteID;
  1732. RRETURN(S_OK);
  1733. }
  1734. STDMETHODIMP
  1735. CBackLink::put_RemoteID(THIS_ long lnRemoteID)
  1736. {
  1737. _dwRemoteID = lnRemoteID;
  1738. RRETURN(S_OK);
  1739. }
  1740. STDMETHODIMP
  1741. CBackLink::get_ObjectName(THIS_ BSTR FAR * retval)
  1742. {
  1743. HRESULT hr = S_OK;
  1744. hr = ADsAllocString(_lpObjectName, retval);
  1745. RRETURN(hr);
  1746. }
  1747. STDMETHODIMP
  1748. CBackLink::put_ObjectName(THIS_ BSTR bstrObjectName)
  1749. {
  1750. if (!bstrObjectName) {
  1751. RRETURN(E_FAIL);
  1752. }
  1753. if (_lpObjectName) {
  1754. FreeADsStr(_lpObjectName);
  1755. }
  1756. _lpObjectName= AllocADsStr(bstrObjectName);
  1757. if (!_lpObjectName) {
  1758. RRETURN(E_OUTOFMEMORY);
  1759. }
  1760. RRETURN(S_OK);
  1761. }
  1762. //////////////////////////////////////////////////////////////////////////
  1763. DEFINE_IDispatch_Implementation(CTypedName)
  1764. CTypedName::CTypedName():
  1765. _pDispMgr(NULL),
  1766. _lpObjectName(NULL),
  1767. _dwLevel(0),
  1768. _dwInterval(0)
  1769. {
  1770. ENLIST_TRACKING(CTypedName);
  1771. }
  1772. HRESULT
  1773. CTypedName::CreateTypedName(
  1774. REFIID riid,
  1775. void **ppvObj
  1776. )
  1777. {
  1778. CTypedName FAR * pTypedName = NULL;
  1779. HRESULT hr = S_OK;
  1780. hr = AllocateTypedNameObject(&pTypedName);
  1781. BAIL_ON_FAILURE(hr);
  1782. hr = pTypedName->QueryInterface(riid, ppvObj);
  1783. BAIL_ON_FAILURE(hr);
  1784. pTypedName->Release();
  1785. RRETURN(hr);
  1786. error:
  1787. delete pTypedName;
  1788. RRETURN(hr);
  1789. }
  1790. CTypedName::~CTypedName( )
  1791. {
  1792. delete _pDispMgr;
  1793. if (_lpObjectName) {
  1794. FreeADsStr(_lpObjectName);
  1795. }
  1796. }
  1797. STDMETHODIMP
  1798. CTypedName::QueryInterface(
  1799. REFIID iid,
  1800. LPVOID FAR* ppv
  1801. )
  1802. {
  1803. if (IsEqualIID(iid, IID_IUnknown))
  1804. {
  1805. *ppv = (IADsTypedName FAR *) this;
  1806. }
  1807. else if (IsEqualIID(iid, IID_IADsTypedName))
  1808. {
  1809. *ppv = (IADsTypedName FAR *) this;
  1810. }
  1811. else if (IsEqualIID(iid, IID_IDispatch))
  1812. {
  1813. *ppv = (IADsTypedName FAR *) this;
  1814. }
  1815. else
  1816. {
  1817. *ppv = NULL;
  1818. return E_NOINTERFACE;
  1819. }
  1820. AddRef();
  1821. return NOERROR;
  1822. }
  1823. HRESULT
  1824. CTypedName::AllocateTypedNameObject(
  1825. CTypedName ** ppTypedName
  1826. )
  1827. {
  1828. CTypedName FAR * pTypedName = NULL;
  1829. CDispatchMgr FAR * pDispMgr = NULL;
  1830. HRESULT hr = S_OK;
  1831. pTypedName = new CTypedName();
  1832. if (pTypedName == NULL) {
  1833. hr = E_OUTOFMEMORY;
  1834. }
  1835. BAIL_ON_FAILURE(hr);
  1836. pDispMgr = new CDispatchMgr;
  1837. if (pDispMgr == NULL) {
  1838. hr = E_OUTOFMEMORY;
  1839. }
  1840. BAIL_ON_FAILURE(hr);
  1841. hr = LoadTypeInfoEntry(
  1842. pDispMgr,
  1843. LIBID_ADs,
  1844. IID_IADsTypedName,
  1845. (IADsTypedName *)pTypedName,
  1846. DISPID_REGULAR
  1847. );
  1848. BAIL_ON_FAILURE(hr);
  1849. pTypedName->_pDispMgr = pDispMgr;
  1850. *ppTypedName = pTypedName;
  1851. RRETURN(hr);
  1852. error:
  1853. delete pDispMgr;
  1854. RRETURN(hr);
  1855. }
  1856. STDMETHODIMP
  1857. CTypedName::get_Interval(THIS_ long FAR * retval)
  1858. {
  1859. *retval = _dwInterval;
  1860. RRETURN(S_OK);
  1861. }
  1862. STDMETHODIMP
  1863. CTypedName::put_Interval(THIS_ long lnInterval)
  1864. {
  1865. _dwInterval = lnInterval;
  1866. RRETURN(S_OK);
  1867. }
  1868. STDMETHODIMP
  1869. CTypedName::get_Level(THIS_ long FAR * retval)
  1870. {
  1871. *retval = _dwLevel;
  1872. RRETURN(S_OK);
  1873. }
  1874. STDMETHODIMP
  1875. CTypedName::put_Level(THIS_ long lnLevel)
  1876. {
  1877. _dwLevel = lnLevel;
  1878. RRETURN(S_OK);
  1879. }
  1880. STDMETHODIMP
  1881. CTypedName::get_ObjectName(THIS_ BSTR FAR * retval)
  1882. {
  1883. HRESULT hr = S_OK;
  1884. hr = ADsAllocString(_lpObjectName, retval);
  1885. RRETURN(hr);
  1886. }
  1887. STDMETHODIMP
  1888. CTypedName::put_ObjectName(THIS_ BSTR bstrObjectName)
  1889. {
  1890. if (!bstrObjectName) {
  1891. RRETURN(E_FAIL);
  1892. }
  1893. if (_lpObjectName) {
  1894. FreeADsStr(_lpObjectName);
  1895. }
  1896. _lpObjectName= AllocADsStr(bstrObjectName);
  1897. if (!_lpObjectName) {
  1898. RRETURN(E_OUTOFMEMORY);
  1899. }
  1900. RRETURN(S_OK);
  1901. }
  1902. DEFINE_IDispatch_Implementation(CHold)
  1903. CHold::CHold():
  1904. _pDispMgr(NULL),
  1905. _lpObjectName(NULL),
  1906. _dwAmount(0)
  1907. {
  1908. ENLIST_TRACKING(CHold);
  1909. }
  1910. HRESULT
  1911. CHold::CreateHold(
  1912. REFIID riid,
  1913. void **ppvObj
  1914. )
  1915. {
  1916. CHold FAR * pHold = NULL;
  1917. HRESULT hr = S_OK;
  1918. hr = AllocateHoldObject(&pHold);
  1919. BAIL_ON_FAILURE(hr);
  1920. hr = pHold->QueryInterface(riid, ppvObj);
  1921. BAIL_ON_FAILURE(hr);
  1922. pHold->Release();
  1923. RRETURN(hr);
  1924. error:
  1925. delete pHold;
  1926. RRETURN(hr);
  1927. }
  1928. CHold::~CHold( )
  1929. {
  1930. delete _pDispMgr;
  1931. if (_lpObjectName) {
  1932. FreeADsStr(_lpObjectName);
  1933. }
  1934. }
  1935. STDMETHODIMP
  1936. CHold::QueryInterface(
  1937. REFIID iid,
  1938. LPVOID FAR* ppv
  1939. )
  1940. {
  1941. if (IsEqualIID(iid, IID_IUnknown))
  1942. {
  1943. *ppv = (IADsHold FAR *) this;
  1944. }
  1945. else if (IsEqualIID(iid, IID_IADsHold))
  1946. {
  1947. *ppv = (IADsHold FAR *) this;
  1948. }
  1949. else if (IsEqualIID(iid, IID_IDispatch))
  1950. {
  1951. *ppv = (IADsHold FAR *) this;
  1952. }
  1953. else
  1954. {
  1955. *ppv = NULL;
  1956. return E_NOINTERFACE;
  1957. }
  1958. AddRef();
  1959. return NOERROR;
  1960. }
  1961. HRESULT
  1962. CHold::AllocateHoldObject(
  1963. CHold ** ppHold
  1964. )
  1965. {
  1966. CHold FAR * pHold = NULL;
  1967. CDispatchMgr FAR * pDispMgr = NULL;
  1968. HRESULT hr = S_OK;
  1969. pHold = new CHold();
  1970. if (pHold == NULL) {
  1971. hr = E_OUTOFMEMORY;
  1972. }
  1973. BAIL_ON_FAILURE(hr);
  1974. pDispMgr = new CDispatchMgr;
  1975. if (pDispMgr == NULL) {
  1976. hr = E_OUTOFMEMORY;
  1977. }
  1978. BAIL_ON_FAILURE(hr);
  1979. hr = LoadTypeInfoEntry(
  1980. pDispMgr,
  1981. LIBID_ADs,
  1982. IID_IADsHold,
  1983. (IADsHold *)pHold,
  1984. DISPID_REGULAR
  1985. );
  1986. BAIL_ON_FAILURE(hr);
  1987. pHold->_pDispMgr = pDispMgr;
  1988. *ppHold = pHold;
  1989. RRETURN(hr);
  1990. error:
  1991. delete pDispMgr;
  1992. RRETURN(hr);
  1993. }
  1994. STDMETHODIMP
  1995. CHold::get_Amount(THIS_ long FAR * retval)
  1996. {
  1997. *retval = _dwAmount;
  1998. RRETURN(S_OK);
  1999. }
  2000. STDMETHODIMP
  2001. CHold::put_Amount(THIS_ long lnAmount)
  2002. {
  2003. _dwAmount = lnAmount;
  2004. RRETURN(S_OK);
  2005. }
  2006. STDMETHODIMP
  2007. CHold::get_ObjectName(THIS_ BSTR FAR * retval)
  2008. {
  2009. HRESULT hr = S_OK;
  2010. hr = ADsAllocString(_lpObjectName, retval);
  2011. RRETURN(hr);
  2012. }
  2013. STDMETHODIMP
  2014. CHold::put_ObjectName(THIS_ BSTR bstrObjectName)
  2015. {
  2016. if (!bstrObjectName) {
  2017. RRETURN(E_FAIL);
  2018. }
  2019. if (_lpObjectName) {
  2020. FreeADsStr(_lpObjectName);
  2021. }
  2022. _lpObjectName= AllocADsStr(bstrObjectName);
  2023. if (!_lpObjectName) {
  2024. RRETURN(E_OUTOFMEMORY);
  2025. }
  2026. RRETURN(S_OK);
  2027. }