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.

105 lines
2.5 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  5. //
  6. // File: adsxmlcf.cxx
  7. //
  8. // Contents: Contains the class factory for creating ADsXML extension.
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "adsxmlcf.hxx"
  12. #include "adsxml2.h"
  13. #define DISPID_REGULAR 1
  14. const GUID LIBID_ADsXML = {0x61340306,0xe79c,0x401d,{0xa3,0x4a,0xcb,0xbc,0x99,0x19,0x90,0x25}};
  15. const IID IID_IADsXML = {0x91e5c5dc,0x926b,0x46ff,{0x9f,0xdb,0x9f,0xb1,0x12,0xbf,0x10,0xe6}};
  16. //----------------------------------------------------------------------------
  17. // Function: CreateInstance
  18. //
  19. // Synopsis: Creates the ADsXML extension object.
  20. //
  21. // Arguments:
  22. //
  23. // pUnkOuter Pointer to aggregating IUnknown. This has to be non-NULL since
  24. // the extension can't exist by itself.
  25. // iid Interface requested.
  26. // ppInterface Returns pointer to interface requested
  27. //
  28. // Returns: S_OK on success. Error code otherwise.
  29. //
  30. // Modifies: *ppInterface to return a pointer to the interface requested
  31. //
  32. //----------------------------------------------------------------------------
  33. STDMETHODIMP CADsXMLCF::CreateInstance(
  34. IUnknown * pUnkOuter,
  35. REFIID iid,
  36. LPVOID *ppInterface
  37. )
  38. {
  39. HRESULT hr = S_OK;
  40. CADsXML *pCADsXML = NULL;
  41. IADs FAR * pADs = NULL;
  42. CAggregateeDispMgr FAR * pDispMgr = NULL;
  43. if( (NULL == pUnkOuter) || (NULL == ppInterface) )
  44. RRETURN(E_INVALIDARG);
  45. // can only ask for IUnknown
  46. ADsAssert(IsEqualIID(iid, IID_IUnknown));
  47. *ppInterface = NULL;
  48. pCADsXML = new CADsXML();
  49. if(NULL == pCADsXML) {
  50. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  51. }
  52. pCADsXML->_pUnkOuter = pUnkOuter;
  53. pDispMgr = new CAggregateeDispMgr;
  54. if (pDispMgr == NULL) {
  55. hr = E_OUTOFMEMORY;
  56. BAIL_ON_FAILURE(hr);
  57. }
  58. pCADsXML->_pDispMgr = pDispMgr;
  59. hr = pDispMgr->LoadTypeInfoEntry(
  60. LIBID_ADsXML,
  61. IID_IADsXML,
  62. (IADsXML *)pCADsXML,
  63. DISPID_REGULAR
  64. );
  65. BAIL_ON_FAILURE(hr);
  66. hr = pUnkOuter->QueryInterface(
  67. IID_IADs,
  68. (void **)&pADs
  69. );
  70. BAIL_ON_FAILURE(hr);
  71. pADs->Release();
  72. pCADsXML->_pADs = pADs;
  73. *ppInterface = (INonDelegatingUnknown FAR *) pCADsXML;
  74. RRETURN(hr);
  75. error:
  76. if(pCADsXML)
  77. delete pCADsXML;
  78. *ppInterface = NULL;
  79. RRETURN(hr);
  80. }