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.

88 lines
1.8 KiB

  1. /*******************************************************************************
  2. Module:
  3. bgevent.cpp
  4. Abstract:
  5. Class implementing TAPI event
  6. Author:
  7. Qianbo Huai (qhuai) Jan 27 2000
  8. *******************************************************************************/
  9. #include "stdafx.h"
  10. extern HWND ghDlg;
  11. /*//////////////////////////////////////////////////////////////////////////////
  12. ////*/
  13. HRESULT
  14. STDMETHODCALLTYPE
  15. CTAPIEventNotification::QueryInterface (
  16. REFIID iid,
  17. void **ppvObj
  18. )
  19. {
  20. if (iid==IID_ITTAPIEventNotification)
  21. {
  22. AddRef ();
  23. *ppvObj = (void *)this;
  24. return S_OK;
  25. }
  26. if (iid==IID_IUnknown)
  27. {
  28. AddRef ();
  29. *ppvObj = (void *)this;
  30. }
  31. return E_NOINTERFACE;
  32. }
  33. /*//////////////////////////////////////////////////////////////////////////////
  34. ////*/
  35. ULONG
  36. STDMETHODCALLTYPE
  37. CTAPIEventNotification::AddRef ()
  38. {
  39. ULONG l = InterlockedIncrement (&m_dwRefCount);
  40. return l;
  41. }
  42. /*//////////////////////////////////////////////////////////////////////////////
  43. ////*/
  44. ULONG
  45. STDMETHODCALLTYPE
  46. CTAPIEventNotification::Release ()
  47. {
  48. ULONG l = InterlockedDecrement (&m_dwRefCount);
  49. if (0 == l)
  50. {
  51. delete this;
  52. }
  53. return l;
  54. }
  55. /*//////////////////////////////////////////////////////////////////////////////
  56. ////*/
  57. HRESULT
  58. STDMETHODCALLTYPE
  59. CTAPIEventNotification::Event (
  60. TAPI_EVENT TapiEvent,
  61. IDispatch * pEvent
  62. )
  63. {
  64. // Addref the event so it doesn't go away.
  65. pEvent->AddRef();
  66. // Post a message to our own UI thread.
  67. PostMessage(
  68. ghDlg,
  69. WM_PRIVATETAPIEVENT,
  70. (WPARAM) TapiEvent,
  71. (LPARAM) pEvent
  72. );
  73. return S_OK;
  74. }