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.

85 lines
2.1 KiB

  1. /*---------------------------------------------------------------------------
  2. File: MapiUtil.cpp
  3. Comments: COM helper object that enumerates MAPI profiles on a computer, and
  4. containers in the exchange directory. This is used by the GUI to show the available
  5. mapi profiles and containers for selection.
  6. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  7. Proprietary and confidential to Mission Critical Software, Inc.
  8. REVISION LOG ENTRY
  9. Revision By: Christy Boles
  10. Revised on 07/01/99
  11. ---------------------------------------------------------------------------
  12. */// MapiUtil.cpp : Implementation of CMapiUtil
  13. #include "stdafx.h"
  14. #include "McsMapi.h"
  15. #include "MapiUtil.h"
  16. #include "ListProf.h"
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CMapiUtil
  19. STDMETHODIMP CMapiUtil::ListContainers(BSTR profile, IUnknown **pUnkOut)
  20. {
  21. HRESULT hr = S_OK;
  22. IVarSetPtr pVarSet(CLSID_VarSet);
  23. IUnknownPtr pUnk;
  24. hr = ::ListContainers((WCHAR*)profile,pVarSet);
  25. if ( FAILED(hr) )
  26. {
  27. pVarSet->put("McsMapiUtil.ErrorCode",hr);
  28. hr = S_OK;
  29. }
  30. pUnk = pVarSet;
  31. (*pUnkOut) = pUnk;
  32. (*pUnkOut)->AddRef();
  33. return hr;
  34. }
  35. STDMETHODIMP CMapiUtil::ListProfiles(IUnknown **pUnkOut)
  36. {
  37. HRESULT hr = S_OK;
  38. IVarSetPtr pVarSet(CLSID_VarSet);
  39. IUnknownPtr pUnk;
  40. hr = ::ListProfiles(pVarSet);
  41. if ( FAILED(hr) )
  42. {
  43. pVarSet->put("McsMapiUtil.ErrorCode",hr);
  44. hr = S_OK;
  45. }
  46. pUnk = pVarSet;
  47. (*pUnkOut) = pUnk;
  48. (*pUnkOut)->AddRef();
  49. return hr;
  50. }
  51. STDMETHODIMP CMapiUtil::ProfileGetServer(BSTR profile, BSTR *exchangeServer)
  52. {
  53. WCHAR computername[MAX_PATH];
  54. HRESULT hr = S_OK;
  55. hr = ::ProfileGetServer(NULL,(WCHAR*)profile,computername);
  56. if ( SUCCEEDED(hr) )
  57. {
  58. (*exchangeServer) = SysAllocString(computername);
  59. }
  60. else
  61. {
  62. (*exchangeServer) = NULL;
  63. }
  64. return hr;
  65. }