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.

143 lines
2.7 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: cprovcf.cxx
  7. //
  8. // Contents: Windows NT 3.5 Provider Object Class Factory Code
  9. //
  10. // CADsProviderCF::CreateInstance
  11. //
  12. // History: 01-30-95 krishnag Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "oleds.hxx"
  16. #pragma hdrstop
  17. // Class CADsProvider
  18. CADsProvider::CADsProvider()
  19. {
  20. }
  21. HRESULT
  22. CADsProvider::Create(CADsProvider FAR * FAR * ppProvider)
  23. {
  24. CADsProvider FAR * pProvider = NULL;
  25. HRESULT hr = S_OK;
  26. //Create the Provider Object
  27. pProvider = new CADsProvider();
  28. if (pProvider == NULL) {
  29. RRETURN(ResultFromScode(E_OUTOFMEMORY));
  30. }
  31. if (FAILED(hr)) {
  32. delete pProvider;
  33. RRETURN(hr);
  34. }
  35. *ppProvider = pProvider;
  36. RRETURN(hr);
  37. }
  38. CADsProvider::~CADsProvider( )
  39. {
  40. ENLIST_TRACKING(CADsProvider);
  41. }
  42. STDMETHODIMP
  43. CADsProvider::QueryInterface(REFIID iid, LPVOID FAR* ppv)
  44. {
  45. if (IsEqualIID(iid, IID_IUnknown))
  46. {
  47. *ppv = this;
  48. }
  49. else if (IsEqualIID(iid, IID_IParseDisplayName))
  50. {
  51. *ppv = (IParseDisplayName FAR *) this;
  52. }
  53. else
  54. {
  55. *ppv = NULL;
  56. return E_NOINTERFACE;
  57. }
  58. AddRef();
  59. return NOERROR;
  60. }
  61. STDMETHODIMP
  62. CADsProvider::ParseDisplayName(IBindCtx* pbc, WCHAR* szDisplayName, ULONG* pchEaten, IMoniker** ppmk)
  63. {
  64. HRESULT hr;
  65. *ppmk = NULL;
  66. if (pchEaten != NULL){
  67. *pchEaten = 0;
  68. }
  69. hr = ResolvePathName(
  70. pbc,
  71. szDisplayName,
  72. pchEaten,
  73. ppmk
  74. );
  75. RRETURN(hr);
  76. }
  77. HRESULT
  78. CADsProvider::ResolvePathName(IBindCtx* pbc,
  79. WCHAR* szDisplayName,
  80. ULONG* pchEaten,
  81. IMoniker** ppmk
  82. )
  83. {
  84. HRESULT hr = S_OK;
  85. LPUNKNOWN pUnknown = NULL;
  86. if (!pchEaten) {
  87. BAIL_IF_ERROR(hr = E_INVALIDARG);
  88. }
  89. *pchEaten = 0;
  90. //
  91. // The ADs: Path would only work if it contains the exact
  92. // text L"ADs:" or L"ADs://" for backward compatibility.
  93. //
  94. if ((_wcsicmp(szDisplayName,L"ADs:") != 0)
  95. && (_wcsicmp(szDisplayName, L"ADs://") != 0 )) {
  96. hr = E_ADS_BAD_PATHNAME;
  97. BAIL_IF_ERROR(hr);
  98. }
  99. hr = CADsNamespaces::CreateNamespaces(
  100. L"",
  101. L"ADs:",
  102. ADS_OBJECT_BOUND,
  103. IID_IUnknown,
  104. (void **)&pUnknown
  105. );
  106. BAIL_IF_ERROR(hr);
  107. hr = CreatePointerMoniker(pUnknown, ppmk);
  108. *pchEaten += wcslen(szDisplayName);
  109. cleanup:
  110. if (pUnknown) {
  111. pUnknown->Release();
  112. }
  113. RRETURN (hr);
  114. }