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.

137 lines
2.6 KiB

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