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.

87 lines
1.8 KiB

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