Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

910 lines
21 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: cdldelg.cxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 02-20-97 t-alans (Alan Shi) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include <trans.h>
  18. #include <wchar.h>
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Method: CCDLDelegate::CCDLDelegate
  22. //
  23. // Synopsis:
  24. //
  25. // Arguments:
  26. //
  27. //
  28. //
  29. // Returns:
  30. //
  31. // History: 01-27-1997 t-alans (Alan Shi) Created
  32. //
  33. // Notes:
  34. //
  35. //----------------------------------------------------------------------------
  36. CCDLDelegate::CCDLDelegate(CBinding *pCBinding, IBindStatusCallback *pBSC)
  37. {
  38. DEBUG_ENTER((DBG_TRANS,
  39. None,
  40. "CCDLDelegate::CCDLDelegate",
  41. "this=%#x, %#x, %#x",
  42. this, pCBinding, pBSC
  43. ));
  44. _cRef = 1;
  45. _pCBinding = pCBinding;
  46. if (_pCBinding != NULL)
  47. {
  48. _pCBinding->AddRef();
  49. }
  50. _pBSC = pBSC;
  51. if (_pBSC != NULL)
  52. {
  53. _pBSC->AddRef();
  54. }
  55. DEBUG_LEAVE(0);
  56. }
  57. //+---------------------------------------------------------------------------
  58. //
  59. // Method: CCDLDelegate::~CCDLDelegate
  60. //
  61. // Synopsis:
  62. //
  63. // Arguments:
  64. //
  65. //
  66. //
  67. // Returns:
  68. //
  69. // History: 01-27-1997 t-alans (Alan Shi) Created
  70. //
  71. // Notes:
  72. //
  73. //----------------------------------------------------------------------------
  74. CCDLDelegate::~CCDLDelegate()
  75. {
  76. DEBUG_ENTER((DBG_TRANS,
  77. None,
  78. "CCDLDelegate::~CCDLDelegate",
  79. "this=%#x",
  80. this
  81. ));
  82. if (_pCBinding != NULL)
  83. {
  84. _pCBinding->Release();
  85. }
  86. if (_pBSC != NULL)
  87. {
  88. _pBSC->Release();
  89. }
  90. DEBUG_LEAVE(0);
  91. }
  92. /*
  93. *
  94. * IUnknown Methods
  95. *
  96. */
  97. //+---------------------------------------------------------------------------
  98. //
  99. // Method: CCDLDelegate::QueryInterface
  100. //
  101. // Synopsis:
  102. //
  103. // Arguments:
  104. //
  105. //
  106. //
  107. // Returns:
  108. //
  109. // History: 01-27-1997 t-alans (Alan Shi) Created
  110. //
  111. // Notes:
  112. //
  113. //----------------------------------------------------------------------------
  114. STDMETHODIMP CCDLDelegate::QueryInterface(REFIID riid, void **ppv)
  115. {
  116. DEBUG_ENTER((DBG_TRANS,
  117. Hresult,
  118. "CCDLDelegate::IUnknown::QueryInterface",
  119. "this=%#x, %#x, %#x",
  120. this, &riid, ppv
  121. ));
  122. HRESULT hr = E_NOINTERFACE;
  123. *ppv = NULL;
  124. if (riid == IID_IUnknown || riid == IID_IBindStatusCallback)
  125. {
  126. *ppv = (IBindStatusCallback *)this;
  127. }
  128. else if (riid == IID_IBinding)
  129. {
  130. *ppv = (IBinding *)this;
  131. }
  132. else if (riid == IID_IWindowForBindingUI)
  133. {
  134. *ppv = (IWindowForBindingUI *)this;
  135. }
  136. if (*ppv != NULL)
  137. {
  138. ((IUnknown *)*ppv)->AddRef();
  139. hr = S_OK;
  140. }
  141. DEBUG_LEAVE(hr);
  142. return hr;
  143. }
  144. //+---------------------------------------------------------------------------
  145. //
  146. // Method: CCDLDelegate::AddRef
  147. //
  148. // Synopsis:
  149. //
  150. // Arguments:
  151. //
  152. //
  153. //
  154. // Returns:
  155. //
  156. // History: 01-27-1997 t-alans (Alan Shi) Created
  157. //
  158. // Notes:
  159. //
  160. //----------------------------------------------------------------------------
  161. STDMETHODIMP_(ULONG) CCDLDelegate::AddRef()
  162. {
  163. DEBUG_ENTER((DBG_TRANS,
  164. Dword,
  165. "CCDLDelegate::IUnknown::AddRef",
  166. "this=%#x",
  167. this
  168. ));
  169. ULONG ulRet = ++_cRef;
  170. DEBUG_LEAVE(ulRet);
  171. return ulRet;
  172. }
  173. //+---------------------------------------------------------------------------
  174. //
  175. // Method: CCDLDelegate::Release
  176. //
  177. // Synopsis:
  178. //
  179. // Arguments:
  180. //
  181. //
  182. //
  183. // Returns:
  184. //
  185. // History: 01-27-1997 t-alans (Alan Shi) Created
  186. //
  187. // Notes:
  188. //
  189. //----------------------------------------------------------------------------
  190. STDMETHODIMP_(ULONG) CCDLDelegate::Release()
  191. {
  192. DEBUG_ENTER((DBG_TRANS,
  193. Dword,
  194. "CCDLDelegate::IUnknown::Release",
  195. "this=%#x",
  196. this
  197. ));
  198. if (--_cRef)
  199. {
  200. DEBUG_LEAVE(_cRef);
  201. return _cRef;
  202. }
  203. delete this;
  204. DEBUG_LEAVE(0);
  205. return 0;
  206. }
  207. /*
  208. *
  209. * IBindStatusCallback Methods
  210. *
  211. */
  212. //+---------------------------------------------------------------------------
  213. //
  214. // Method: CCDLDelegate::OnStartBinding
  215. //
  216. // Synopsis:
  217. //
  218. // Arguments:
  219. //
  220. //
  221. //
  222. // Returns:
  223. //
  224. // History: 01-27-1997 t-alans (Alan Shi) Created
  225. //
  226. // Notes:
  227. //
  228. //----------------------------------------------------------------------------
  229. STDMETHODIMP CCDLDelegate::OnStartBinding(DWORD grfBSCOption, IBinding *pib)
  230. {
  231. DEBUG_ENTER((DBG_TRANS,
  232. Hresult,
  233. "CCDLDelegate::IBindStatusCallback::OnStartBinding",
  234. "this=%#x, %#x, %#x",
  235. this, grfBSCOption, pib
  236. ));
  237. HRESULT hr = S_OK;
  238. #if 0
  239. if (_pCBinding != NULL)
  240. {
  241. hr = _pCBinding->OnTransNotification(BINDSTATUS_???,
  242. 0, 0, S_OK);
  243. }
  244. #endif
  245. _pBinding = pib;
  246. if (_pBinding != NULL)
  247. {
  248. _pBinding->AddRef();
  249. }
  250. DEBUG_LEAVE(hr);
  251. return hr;
  252. }
  253. //+---------------------------------------------------------------------------
  254. //
  255. // Method: CCDLDelegate::OnStopBinding
  256. //
  257. // Synopsis:
  258. //
  259. // Arguments:
  260. //
  261. //
  262. //
  263. // Returns:
  264. //
  265. // History: 01-27-1997 t-alans (Alan Shi) Created
  266. //
  267. // Notes:
  268. //
  269. //----------------------------------------------------------------------------
  270. STDMETHODIMP CCDLDelegate::OnStopBinding(HRESULT hresult, LPCWSTR szError)
  271. {
  272. DEBUG_ENTER((DBG_TRANS,
  273. Hresult,
  274. "CCDLDelegate::IBindStatusCallback::OnStopBinding",
  275. "this=%#x, %#x, %.80wq",
  276. this, hresult, szError
  277. ));
  278. HRESULT hr = S_OK;
  279. #if 0
  280. if (_pCBinding != NULL)
  281. {
  282. hr = _pCBinding->OnTransNotification(BINDSTATUS_CODEDOWNLOADCOMPLETE,
  283. 0, 0, (LPWSTR)szError, hresult);
  284. }
  285. #endif
  286. if (_pBinding != NULL)
  287. {
  288. _pBinding->Release();
  289. _pBinding = NULL;
  290. }
  291. DEBUG_LEAVE(hr);
  292. return hr;
  293. }
  294. //+---------------------------------------------------------------------------
  295. //
  296. // Method: CCDLDelegate::OnObjectAvailable
  297. //
  298. // Synopsis:
  299. //
  300. // Arguments:
  301. //
  302. //
  303. //
  304. // Returns:
  305. //
  306. // History: 01-27-1997 t-alans (Alan Shi) Created
  307. //
  308. // Notes:
  309. //
  310. //----------------------------------------------------------------------------
  311. STDMETHODIMP CCDLDelegate::OnObjectAvailable(REFIID riid, IUnknown *punk)
  312. {
  313. DEBUG_ENTER((DBG_TRANS,
  314. Hresult,
  315. "CCDLDelegate::IBindStatusCallback::OnObjectAvailable",
  316. "this=%#x, %#x, %#x",
  317. this, &riid, punk
  318. ));
  319. DEBUG_LEAVE(S_OK);
  320. return S_OK;
  321. }
  322. //+---------------------------------------------------------------------------
  323. //
  324. // Method: CCDLDelegate::OnLowResource
  325. //
  326. // Synopsis:
  327. //
  328. // Arguments:
  329. //
  330. //
  331. //
  332. // Returns:
  333. //
  334. // History: 01-27-1997 t-alans (Alan Shi) Created
  335. //
  336. // Notes:
  337. //
  338. //----------------------------------------------------------------------------
  339. STDMETHODIMP CCDLDelegate::OnLowResource(DWORD dwReserved)
  340. {
  341. DEBUG_ENTER((DBG_TRANS,
  342. Hresult,
  343. "CCDLDelegate::IBindStatusCallback::OnLowResource",
  344. "this=%#x, %#x",
  345. this, dwReserved
  346. ));
  347. DEBUG_LEAVE(S_OK);
  348. return S_OK;
  349. }
  350. //+---------------------------------------------------------------------------
  351. //
  352. // Method: CCDLDelegate::OnProgress
  353. //
  354. // Synopsis:
  355. //
  356. // Arguments:
  357. //
  358. //
  359. //
  360. // Returns:
  361. //
  362. // History: 01-27-1997 t-alans (Alan Shi) Created
  363. //
  364. // Notes:
  365. //
  366. //----------------------------------------------------------------------------
  367. STDMETHODIMP CCDLDelegate::OnProgress(ULONG ulProgress, ULONG ulProgressMax,
  368. ULONG ulStatusCode,
  369. LPCWSTR szStatusText)
  370. {
  371. DEBUG_ENTER((DBG_TRANS,
  372. Hresult,
  373. "CCDLDelegate::IBindStatusCallback::OnProgress",
  374. "this=%#x, %#x, %#x, %#x, %.80wq",
  375. this, ulProgress, ulProgressMax ulStatusCode, szStatusText
  376. ));
  377. HRESULT hr = S_OK;
  378. DEBUG_LEAVE(hr);
  379. return hr;
  380. }
  381. //+---------------------------------------------------------------------------
  382. //
  383. // Method: CCDLDelegate::GetBindInfo
  384. //
  385. // Synopsis:
  386. //
  387. // Arguments:
  388. //
  389. //
  390. //
  391. // Returns:
  392. //
  393. // History: 01-27-1997 t-alans (Alan Shi) Created
  394. //
  395. // Notes:
  396. //
  397. //----------------------------------------------------------------------------
  398. STDMETHODIMP CCDLDelegate::GetBindInfo(DWORD *pgrfBINDF,
  399. BINDINFO *pbindInfo)
  400. {
  401. DEBUG_ENTER((DBG_TRANS,
  402. Hresult,
  403. "CCDLDelegate::IBindStatusCallback::GetBindInfo",
  404. "this=%#x, %#x, %#x",
  405. this, pgrfBINDF, pbindInfo
  406. ));
  407. *pgrfBINDF |= BINDF_ASYNCSTORAGE;
  408. *pgrfBINDF |= BINDF_PULLDATA;
  409. *pgrfBINDF |= BINDF_ASYNCHRONOUS;
  410. DEBUG_LEAVE(S_OK);
  411. return S_OK;
  412. }
  413. //+---------------------------------------------------------------------------
  414. //
  415. // Method: CCDLDelegate::OnDataAvailable
  416. //
  417. // Synopsis:
  418. //
  419. // Arguments:
  420. //
  421. //
  422. //
  423. // Returns:
  424. //
  425. // History: 01-27-1997 t-alans (Alan Shi) Created
  426. //
  427. // Notes:
  428. //
  429. //----------------------------------------------------------------------------
  430. STDMETHODIMP CCDLDelegate::OnDataAvailable( DWORD grfBSCF, DWORD dwSize,
  431. FORMATETC *pformatetc,
  432. STGMEDIUM *pstgmed )
  433. {
  434. DEBUG_ENTER((DBG_TRANS,
  435. Hresult,
  436. "CCDLDelegate::IBindStatusCallback::OnDataAvailable",
  437. "this=%#x, %#x, %#x, %#x, %#x",
  438. this, grfBSCF, dwSize, pformatetc, pstgmed
  439. ));
  440. DEBUG_LEAVE(S_OK);
  441. return S_OK;
  442. }
  443. /*
  444. *
  445. * IBinding Methods
  446. *
  447. */
  448. // delegates all calls back to URLMon
  449. //+---------------------------------------------------------------------------
  450. //
  451. // Method: CCDLDelegate::Abort
  452. //
  453. // Synopsis:
  454. //
  455. // Arguments:
  456. //
  457. //
  458. //
  459. // Returns:
  460. //
  461. // History: 01-27-1997 t-alans (Alan Shi) Created
  462. //
  463. // Notes:
  464. //
  465. //----------------------------------------------------------------------------
  466. STDMETHODIMP CCDLDelegate::Abort(void)
  467. {
  468. DEBUG_ENTER((DBG_TRANS,
  469. Hresult,
  470. "CCDLDelegate::IBinding::Abort",
  471. "this=%#x",
  472. this
  473. ));
  474. HRESULT hr = E_NOTIMPL;
  475. if (_pBinding != NULL)
  476. {
  477. hr = _pBinding->Abort();
  478. }
  479. DEBUG_LEAVE(hr);
  480. return hr;
  481. }
  482. //+---------------------------------------------------------------------------
  483. //
  484. // Method: CCDLDelegate::Suspend
  485. //
  486. // Synopsis:
  487. //
  488. // Arguments:
  489. //
  490. //
  491. //
  492. // Returns:
  493. //
  494. // History: 01-27-1997 t-alans (Alan Shi) Created
  495. //
  496. // Notes:
  497. //
  498. //----------------------------------------------------------------------------
  499. STDMETHODIMP CCDLDelegate::Suspend(void)
  500. {
  501. DEBUG_ENTER((DBG_TRANS,
  502. Hresult,
  503. "CCDLDelegate::IBinding::Suspend",
  504. "this=%#x",
  505. this
  506. ));
  507. HRESULT hr = E_NOTIMPL;
  508. if (_pBinding != NULL)
  509. {
  510. hr = _pBinding->Suspend();
  511. }
  512. DEBUG_LEAVE(hr);
  513. return hr;
  514. }
  515. //+---------------------------------------------------------------------------
  516. //
  517. // Method: CCDLDelegate::Resume
  518. //
  519. // Synopsis:
  520. //
  521. // Arguments:
  522. //
  523. //
  524. //
  525. // Returns:
  526. //
  527. // History: 01-27-1997 t-alans (Alan Shi) Created
  528. //
  529. // Notes:
  530. //
  531. //----------------------------------------------------------------------------
  532. STDMETHODIMP CCDLDelegate::Resume(void)
  533. {
  534. DEBUG_ENTER((DBG_TRANS,
  535. Hresult,
  536. "CCDLDelegate::IBinding::Resume",
  537. "this=%#x",
  538. this
  539. ));
  540. HRESULT hr = E_NOTIMPL;
  541. if (_pBinding != NULL)
  542. {
  543. hr = _pBinding->Resume();
  544. }
  545. DEBUG_LEAVE(hr);
  546. return hr;
  547. }
  548. //+---------------------------------------------------------------------------
  549. //
  550. // Method: CCDLDelegate::SetPriority
  551. //
  552. // Synopsis:
  553. //
  554. // Arguments:
  555. //
  556. //
  557. //
  558. // Returns:
  559. //
  560. // History: 01-27-1997 t-alans (Alan Shi) Created
  561. //
  562. // Notes:
  563. //
  564. //----------------------------------------------------------------------------
  565. STDMETHODIMP CCDLDelegate::SetPriority(LONG nPriority)
  566. {
  567. DEBUG_ENTER((DBG_TRANS,
  568. Hresult,
  569. "CCDLDelegate::IBinding::SetPriority",
  570. "this=%#x, %#x",
  571. this, nPriority
  572. ));
  573. HRESULT hr = E_NOTIMPL;
  574. if (_pBinding != NULL)
  575. {
  576. hr = _pBinding->SetPriority(nPriority);
  577. }
  578. DEBUG_LEAVE(hr);
  579. return hr;
  580. }
  581. //+---------------------------------------------------------------------------
  582. //
  583. // Method: CCDLDelegate::GetPriority
  584. //
  585. // Synopsis:
  586. //
  587. // Arguments:
  588. //
  589. //
  590. //
  591. // Returns:
  592. //
  593. // History: 01-27-1997 t-alans (Alan Shi) Created
  594. //
  595. // Notes:
  596. //
  597. //----------------------------------------------------------------------------
  598. STDMETHODIMP CCDLDelegate::GetPriority(LONG *pnPriority)
  599. {
  600. DEBUG_ENTER((DBG_TRANS,
  601. Hresult,
  602. "CCDLDelegate::IBinding::GetPriority",
  603. "this=%#x, %#x",
  604. this, pnPriority
  605. ));
  606. HRESULT hr = E_NOTIMPL;
  607. if (_pBinding != NULL)
  608. {
  609. hr = _pBinding->GetPriority(pnPriority);
  610. }
  611. DEBUG_LEAVE(hr);
  612. return hr;
  613. }
  614. //+---------------------------------------------------------------------------
  615. //
  616. // Method: CCDLDelegate::GetBindResult
  617. //
  618. // Synopsis:
  619. //
  620. // Arguments:
  621. //
  622. //
  623. //
  624. // Returns:
  625. //
  626. // History: 01-27-1997 t-alans (Alan Shi) Created
  627. //
  628. // Notes:
  629. //
  630. //----------------------------------------------------------------------------
  631. STDMETHODIMP CCDLDelegate::GetBindResult(CLSID *pclsidProtocol,
  632. DWORD *pdwBindResult,
  633. LPWSTR *pszBindResult,
  634. DWORD *dwReserved )
  635. {
  636. DEBUG_ENTER((DBG_TRANS,
  637. Hresult,
  638. "CCDLDelegate::IBinding::GetBindResult",
  639. "this=%#x, %#x, %#x, %#x, %#x",
  640. this, pclsidProtocol, pdwBindResult, pszBindResult, dwReserved
  641. ));
  642. HRESULT hr = E_NOTIMPL;
  643. if (_pBinding != NULL)
  644. {
  645. hr = _pBinding->GetBindResult(pclsidProtocol, pdwBindResult,
  646. pszBindResult, dwReserved);
  647. }
  648. DEBUG_LEAVE(hr);
  649. return hr;
  650. }
  651. /*
  652. *
  653. * IWindowForBindingUI Methods
  654. *
  655. */
  656. //+---------------------------------------------------------------------------
  657. //
  658. // Method: CCDLDelegate::GetWindow
  659. //
  660. // Synopsis:
  661. //
  662. // Arguments:
  663. //
  664. //
  665. //
  666. // Returns:
  667. //
  668. // History: 01-27-1997 t-alans (Alan Shi) Created
  669. //
  670. // Notes:
  671. //
  672. //----------------------------------------------------------------------------
  673. STDMETHODIMP CCDLDelegate::GetWindow(REFGUID rguidReason,
  674. HWND __RPC_FAR *phwnd)
  675. {
  676. DEBUG_ENTER((DBG_TRANS,
  677. Hresult,
  678. "CCDLDelegate::IWindowForBindingUI::GetWindow",
  679. "this=%#x, %#x, %#x",
  680. this, &rguidReason, phwnd
  681. ));
  682. HRESULT hr = S_FALSE;
  683. IWindowForBindingUI *pWindowForBindingUI = NULL;
  684. IServiceProvider *pIServiceProvider = NULL;
  685. hr = _pBSC->QueryInterface(IID_IWindowForBindingUI,
  686. (LPVOID *)&pWindowForBindingUI);
  687. if (FAILED(hr))
  688. {
  689. hr = _pBSC->QueryInterface(IID_IServiceProvider,
  690. (LPVOID *)&pIServiceProvider);
  691. if (SUCCEEDED(hr))
  692. {
  693. pIServiceProvider->QueryService(IID_IWindowForBindingUI,
  694. IID_IWindowForBindingUI,
  695. (LPVOID *)&pWindowForBindingUI);
  696. pIServiceProvider->Release();
  697. }
  698. }
  699. if (pWindowForBindingUI != NULL)
  700. {
  701. hr = pWindowForBindingUI->GetWindow(rguidReason, phwnd);
  702. }
  703. else
  704. {
  705. hr = S_FALSE;
  706. *phwnd = (HWND)INVALID_HANDLE_VALUE;
  707. }
  708. DEBUG_LEAVE(hr);
  709. return hr;
  710. }
  711. /*
  712. *
  713. * Helper API to do code installation
  714. *
  715. */
  716. //+---------------------------------------------------------------------------
  717. //
  718. // Method: AsyncDLCodeInstall
  719. //
  720. // Synopsis:
  721. //
  722. // Arguments:
  723. //
  724. //
  725. //
  726. // Returns:
  727. //
  728. // History: 01-27-1997 t-alans (Alan Shi) Created
  729. //
  730. // Notes:
  731. //
  732. //----------------------------------------------------------------------------
  733. STDMETHODIMP AsyncDLCodeInstall(CBinding *pCBinding,
  734. IBindStatusCallback *pIBSC,
  735. IBinding **ppIBinding,
  736. CCodeDownloadInfo *pCDLInfo)
  737. {
  738. DEBUG_ENTER((DBG_TRANS,
  739. Hresult,
  740. "AsyncDLCodeInstall",
  741. "%#x, %#x, %#x, %#x",
  742. pCBinding, pIBSC, ppIBinding, pCDLInfo
  743. ));
  744. HRESULT hr = E_FAIL;
  745. CCDLDelegate *pCDLDelegate = NULL;
  746. IBindCtx *pbc = NULL;
  747. IMoniker *pIMonikerCDL = NULL;
  748. IStream *pIStream = NULL;
  749. WCHAR szDisplayName[3 * (MAX_URL_SIZE + 1)];
  750. CLSID clsid = CLSID_NULL;
  751. LPWSTR pszStr = NULL;
  752. WCHAR pszCodeBase[MAX_URL_SIZE + 1];
  753. DWORD dwMajorVersion = 0;
  754. DWORD dwMinorVersion = 0;
  755. pCDLDelegate = new CCDLDelegate(pCBinding, pIBSC);
  756. if (pCDLDelegate == NULL)
  757. {
  758. hr = E_OUTOFMEMORY;
  759. goto Exit;
  760. }
  761. *ppIBinding = pCDLDelegate;
  762. hr = CreateBindCtx(0, &pbc);
  763. if (SUCCEEDED(hr))
  764. {
  765. hr = RegisterBindStatusCallback(pbc, pCDLDelegate, NULL, 0);
  766. if (SUCCEEDED(hr))
  767. {
  768. pCDLDelegate->Release();
  769. }
  770. else
  771. {
  772. pbc->Release();
  773. goto Exit;
  774. }
  775. // AS TODO: Make this smarter...
  776. LPWSTR pszPtr = pszCodeBase;
  777. pCDLInfo->GetCodeBase(&pszPtr);
  778. pCDLInfo->GetClassID(&clsid);
  779. pCDLInfo->GetMajorVersion(&dwMajorVersion);
  780. pCDLInfo->GetMinorVersion(&dwMinorVersion);
  781. HRESULT succ = StringFromCLSID(clsid, &pszStr);
  782. swprintf(szDisplayName, L"cdl:codebase=%s;clsid=%s;verMS=%ld;verLS=%ld"
  783. , pszCodeBase, pszStr, dwMajorVersion, dwMinorVersion);
  784. if (pszStr != NULL)
  785. {
  786. delete pszStr;
  787. }
  788. // assert( strlen( szDisplayName <= 3 * MAX_URL_SIZE ) );
  789. hr = CreateURLMoniker(NULL, szDisplayName, &pIMonikerCDL);
  790. if (SUCCEEDED(hr))
  791. {
  792. hr = pIMonikerCDL->BindToStorage(pbc, NULL, IID_IStream,
  793. (void **)&pIStream);
  794. pIMonikerCDL->Release();
  795. }
  796. }
  797. if (pbc != NULL)
  798. {
  799. pbc->Release();
  800. }
  801. Exit:
  802. DEBUG_LEAVE(hr);
  803. return hr;
  804. }