XTPCalendarMAPIWrapper.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:5k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPCalendarMAPIWrapper.cpp: implementation of the CXTPCalendarMAPIWrapper class.
  2. //
  3. // This file is a part of the XTREME CALENDAR MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "XTPCalendarMAPIWrapper.h"
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #define new DEBUG_NEW
  26. #endif
  27. #pragma warning(disable: 4571) // warning C4571: catch(...) blocks compiled with /EHs do not catch or re-throw Structured Exceptions
  28. #define TRY_POINTER_CALL(proc)
  29. try
  30. {
  31. if (m_hMapiDll != NULL && m_ptrWrappers[xtpWrapper##proc] == NULL)
  32. {
  33. m_ptrWrappers[xtpWrapper##proc] = ::GetProcAddress(
  34. m_hMapiDll, xtpWrapperProc##proc);
  35. }
  36. PFN##proc ptr = (PFN##proc)m_ptrWrappers[xtpWrapper##proc];
  37. if (ptr)
  38. {
  39. #define POINTER_CALL (*ptr)
  40. #define CATCH_POINTER_CALL()
  41. }
  42. }
  43. catch (...)
  44. {
  45. }
  46. //===========================================================================
  47. // CXTPCalendarMAPIWrapper class
  48. //===========================================================================
  49. CXTPCalendarMAPIWrapper::CXTPCalendarMAPIWrapper()
  50. {
  51. ZeroMemory(&m_ptrWrappers, sizeof(m_ptrWrappers));
  52. m_hMapiDll = ::LoadLibrary(_T("mapi32.dll"));
  53. }
  54. CXTPCalendarMAPIWrapper::~CXTPCalendarMAPIWrapper()
  55. {
  56. if (m_hMapiDll)
  57. {
  58. FreeLibrary(m_hMapiDll);
  59. }
  60. }
  61. /////////////////////////////////////////////////////////////////////////////
  62. // Wrapped methods
  63. //
  64. HRESULT CXTPCalendarMAPIWrapper::MAPIInitialize(LPVOID lpMapiInit)
  65. {
  66. TRY_POINTER_CALL(MAPIInitialize)
  67. return POINTER_CALL(lpMapiInit);
  68. CATCH_POINTER_CALL()
  69. return E_FAIL;
  70. }
  71. void CXTPCalendarMAPIWrapper::MAPIUninitialize()
  72. {
  73. TRY_POINTER_CALL(MAPIUninitialize)
  74. POINTER_CALL();
  75. CATCH_POINTER_CALL()
  76. }
  77. HRESULT CXTPCalendarMAPIWrapper::MAPILogonEx(ULONG ulUIParam, LPTSTR lpszProfileName, LPTSTR lpszPassword, FLAGS flFlags, LPMAPISESSION FAR * lppSession)
  78. {
  79. TRY_POINTER_CALL(MAPILogonEx)
  80. return POINTER_CALL(ulUIParam, lpszProfileName, lpszPassword, flFlags, lppSession);
  81. CATCH_POINTER_CALL()
  82. return E_FAIL;
  83. }
  84. ULONG CXTPCalendarMAPIWrapper::MAPIFreeBuffer(LPVOID lpBuffer)
  85. {
  86. TRY_POINTER_CALL(MAPIFreeBuffer)
  87. return POINTER_CALL(lpBuffer);
  88. CATCH_POINTER_CALL()
  89. return 1;
  90. }
  91. ULONG CXTPCalendarMAPIWrapper::UlRelease(LPVOID punk)
  92. {
  93. TRY_POINTER_CALL(UlRelease)
  94. return POINTER_CALL(punk);
  95. CATCH_POINTER_CALL()
  96. return 1;
  97. }
  98. void CXTPCalendarMAPIWrapper::FreeProws(LPSRowSet prows)
  99. {
  100. TRY_POINTER_CALL(FreeProws)
  101. POINTER_CALL(prows);
  102. CATCH_POINTER_CALL()
  103. }
  104. HRESULT CXTPCalendarMAPIWrapper::HrQueryAllRows(LPMAPITABLE ptable, LPSPropTagArray ptaga, LPSRestriction pres, LPSSortOrderSet psos, LONG crowsMax, LPSRowSet FAR * pprows)
  105. {
  106. TRY_POINTER_CALL(HrQueryAllRows)
  107. return POINTER_CALL(ptable, ptaga, pres, psos, crowsMax, pprows);
  108. CATCH_POINTER_CALL()
  109. return E_FAIL;
  110. }
  111. HRESULT CXTPCalendarMAPIWrapper::HrGetOneProp(LPMAPIPROP pmp, ULONG ulPropTag, LPSPropValue FAR * ppprop)
  112. {
  113. TRY_POINTER_CALL(HrGetOneProp)
  114. return POINTER_CALL(pmp, ulPropTag, ppprop);
  115. CATCH_POINTER_CALL()
  116. return E_FAIL;
  117. }
  118. HRESULT CXTPCalendarMAPIWrapper::HrSetOneProp(LPMAPIPROP pmp, LPSPropValue pprop)
  119. {
  120. TRY_POINTER_CALL(HrSetOneProp)
  121. return POINTER_CALL(pmp, pprop);
  122. CATCH_POINTER_CALL()
  123. return E_FAIL;
  124. }
  125. SCODE CXTPCalendarMAPIWrapper::MAPIAllocateBuffer(ULONG cbSize, LPVOID FAR * lppBuffer)
  126. {
  127. TRY_POINTER_CALL(MAPIAllocateBuffer)
  128. return POINTER_CALL(cbSize,lppBuffer);
  129. CATCH_POINTER_CALL()
  130. return E_FAIL;
  131. }
  132. HRESULT CXTPCalendarMAPIWrapper::HrThisThreadAdviseSink(LPMAPIADVISESINK lpAdviseSink, LPMAPIADVISESINK FAR * lppAdviseSink)
  133. {
  134. TRY_POINTER_CALL(HrThisThreadAdviseSink)
  135. return POINTER_CALL(lpAdviseSink, lppAdviseSink);
  136. CATCH_POINTER_CALL()
  137. return E_FAIL;
  138. }
  139. HRESULT CXTPCalendarMAPIWrapper::HrAllocAdviseSink(LPNOTIFCALLBACK lpfnCallback, LPVOID lpvContext, LPMAPIADVISESINK FAR * lppAdviseSink)
  140. {
  141. TRY_POINTER_CALL(HrAllocAdviseSink)
  142. return POINTER_CALL(lpfnCallback, lpvContext, lppAdviseSink);
  143. CATCH_POINTER_CALL()
  144. return E_FAIL;
  145. }