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.

140 lines
2.6 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. // CNDSProviderCF::CreateInstance
  11. //
  12. // History: 01-30-95 krishnag Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "nds.hxx"
  16. #pragma hdrstop
  17. // Class CNDSProvider
  18. CNDSProvider::CNDSProvider()
  19. {
  20. }
  21. HRESULT
  22. CNDSProvider::Create(CNDSProvider FAR * FAR * ppProvider)
  23. {
  24. CNDSProvider FAR * pProvider = NULL;
  25. HRESULT hr = S_OK;
  26. //Create the Provider Object
  27. pProvider = new CNDSProvider();
  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. CNDSProvider::~CNDSProvider( )
  39. {
  40. ENLIST_TRACKING(CNDSProvider);
  41. }
  42. STDMETHODIMP
  43. CNDSProvider::QueryInterface(REFIID iid, LPVOID FAR* ppv)
  44. {
  45. if (ppv == NULL) {
  46. RRETURN(E_POINTER);
  47. }
  48. if (IsEqualIID(iid, IID_IUnknown))
  49. {
  50. *ppv = this;
  51. }
  52. else if (IsEqualIID(iid, IID_IParseDisplayName))
  53. {
  54. *ppv = (IParseDisplayName FAR *) this;
  55. }
  56. else
  57. {
  58. *ppv = NULL;
  59. return E_NOINTERFACE;
  60. }
  61. AddRef();
  62. return NOERROR;
  63. }
  64. STDMETHODIMP
  65. CNDSProvider::ParseDisplayName(
  66. IBindCtx* pbc,
  67. WCHAR* szDisplayName,
  68. ULONG* pchEaten,
  69. IMoniker** ppmk
  70. )
  71. {
  72. HRESULT hr;
  73. *ppmk = NULL;
  74. if (pchEaten != NULL){
  75. *pchEaten = 0;
  76. }
  77. hr = ResolvePathName(
  78. pbc,
  79. szDisplayName,
  80. pchEaten,
  81. ppmk
  82. );
  83. RRETURN_EXP_IF_ERR(hr);
  84. }
  85. HRESULT
  86. CNDSProvider::ResolvePathName(
  87. IBindCtx* pbc,
  88. WCHAR* szDisplayName,
  89. ULONG* pchEaten,
  90. IMoniker** ppmk
  91. )
  92. {
  93. HRESULT hr;
  94. LPUNKNOWN pUnknown = NULL;
  95. CCredentials Credentials;
  96. if (!pchEaten) {
  97. BAIL_IF_ERROR(hr = E_INVALIDARG);
  98. }
  99. *pchEaten = 0;
  100. hr = GetObject(
  101. szDisplayName,
  102. Credentials,
  103. (LPVOID *)&pUnknown
  104. );
  105. BAIL_IF_ERROR(hr);
  106. hr = CreatePointerMoniker(pUnknown, ppmk);
  107. BAIL_IF_ERROR(hr);
  108. *pchEaten += wcslen(szDisplayName);
  109. cleanup:
  110. if (pUnknown) {
  111. pUnknown->Release();
  112. }
  113. RRETURN_EXP_IF_ERR(hr);
  114. }