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.

80 lines
1.6 KiB

  1. /*++
  2. Copyright (C) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. template<class TProvider>
  8. CProviderLocator<TProvider>::CProviderLocator()
  9. {
  10. m_cRef=0;
  11. ObjectCreated();
  12. return;
  13. }
  14. template<class TProvider>
  15. CProviderLocator<TProvider>::~CProviderLocator(void)
  16. {
  17. ObjectDestroyed();
  18. return;
  19. }
  20. template<class TProvider>
  21. STDMETHODIMP CProviderLocator<TProvider>::QueryInterface(REFIID riid, PPVOID ppv)
  22. {
  23. *ppv=NULL;
  24. if (IID_IUnknown==riid || riid == IID_IHmmLocator)
  25. *ppv=this;
  26. if (NULL!=*ppv)
  27. {
  28. ((LPUNKNOWN)*ppv)->AddRef();
  29. return NOERROR;
  30. }
  31. return E_NOINTERFACE;
  32. }
  33. template<class TProvider>
  34. STDMETHODIMP_(ULONG) CProviderLocator<TProvider>::AddRef(void)
  35. {
  36. return InterlockedIncrement(&m_cRef);
  37. }
  38. template<class TProvider>
  39. STDMETHODIMP_(ULONG) CProviderLocator<TProvider>::Release(void)
  40. {
  41. LONG cRef = InterlockedDecrement(&m_cRef);
  42. if(cRef == 0)
  43. {
  44. delete this;
  45. }
  46. return cRef;
  47. }
  48. template<class TProvider>
  49. STDMETHODIMP CProviderLocator<TProvider>::ConnectServer(BSTR Path,
  50. BSTR User, BSTR Password,
  51. BSTR LocaleId, long lFlags,
  52. IHmmServices FAR* FAR* ppNamespace)
  53. {
  54. SCODE sc;
  55. // Create a new instance of the provider to handle the namespace.
  56. TProvider * pNew = new TProvider(Path,User,Password);
  57. if(pNew == NULL)
  58. return HMM_E_FAILED;
  59. sc = pNew->QueryInterface(IID_IHmmServices,(void **) ppNamespace);
  60. if(sc != S_OK)
  61. delete pNew;
  62. return sc;
  63. }