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.

135 lines
4.4 KiB

  1. #ifndef _CPTSHOOT_H_
  2. #define _CPTSHOOT_H_
  3. template <class T>
  4. class CProxy_ITSHOOTCtrlEvents : public IConnectionPointImpl<T, &DIID__ITSHOOTCtrlEvents, CComDynamicUnkArray>
  5. {
  6. //Warning this class may be recreated by the wizard.
  7. public:
  8. long Fire_Sniffing(BSTR strNodeName, BSTR strLaunchBasis, BSTR strAdditionalArgs)
  9. {
  10. T* pT = static_cast<T*>(this);
  11. VARIANT resultVariant;
  12. if (RUNNING_APARTMENT_THREADED())
  13. {
  14. CComVariant* pvars = new CComVariant[3];
  15. long result = -1;
  16. V_VT(&resultVariant) = VT_I4;
  17. resultVariant.lVal = result;
  18. pT->Lock();
  19. for(vector<DWORD>::iterator it = pT->m_vecCookies.begin(); it != pT->m_vecCookies.end(); it++)
  20. {
  21. IDispatch* pDispatch = NULL;
  22. pT->m_pGIT->GetInterfaceFromGlobal(*it, IID_IDispatch,
  23. reinterpret_cast<void**>(&pDispatch));
  24. if (pDispatch != NULL)
  25. {
  26. pvars[2] = strNodeName;
  27. pvars[1] = strLaunchBasis;
  28. pvars[0] = strAdditionalArgs;
  29. DISPPARAMS disp = { pvars, NULL, 3, 0 };
  30. HRESULT result = S_OK;
  31. if (SUCCEEDED(result = pDispatch->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &resultVariant, NULL, NULL)))
  32. {
  33. pDispatch->Release();
  34. break;
  35. }
  36. pDispatch->Release();
  37. }
  38. }
  39. pT->Unlock();
  40. delete[] pvars;
  41. }
  42. if (RUNNING_FREE_THREADED())
  43. {
  44. int nConnectionIndex;
  45. CComVariant* pvars = new CComVariant[3];
  46. int nConnections = m_vec.GetSize();
  47. long result = -1;
  48. V_VT(&resultVariant) = VT_I4;
  49. resultVariant.lVal = result;
  50. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  51. {
  52. pT->Lock();
  53. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  54. pT->Unlock();
  55. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  56. if (pDispatch != NULL)
  57. {
  58. pvars[2] = strNodeName;
  59. pvars[1] = strLaunchBasis;
  60. pvars[0] = strAdditionalArgs;
  61. DISPPARAMS disp = { pvars, NULL, 3, 0 };
  62. HRESULT hResult;
  63. if (SUCCEEDED(hResult = pDispatch->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &resultVariant, NULL, NULL)))
  64. break;
  65. }
  66. }
  67. delete[] pvars;
  68. }
  69. return resultVariant.lVal;
  70. }
  71. void Fire_Render(BSTR strPage)
  72. {
  73. T* pT = static_cast<T*>(this);
  74. if (RUNNING_APARTMENT_THREADED())
  75. {
  76. CComVariant* pvars = new CComVariant[1];
  77. pT->Lock();
  78. for(vector<DWORD>::iterator it = pT->m_vecCookies.begin(); it != pT->m_vecCookies.end(); it++)
  79. {
  80. IDispatch* pDispatch = NULL;
  81. pT->m_pGIT->GetInterfaceFromGlobal(*it, IID_IDispatch,
  82. reinterpret_cast<void**>(&pDispatch));
  83. if (pDispatch != NULL)
  84. {
  85. pvars[0] = strPage;
  86. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  87. HRESULT result = S_OK;
  88. if (SUCCEEDED(result = pDispatch->Invoke(2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL)))
  89. {
  90. pDispatch->Release();
  91. break;
  92. }
  93. pDispatch->Release();
  94. }
  95. }
  96. pT->Unlock();
  97. delete[] pvars;
  98. }
  99. if (RUNNING_FREE_THREADED())
  100. {
  101. int nConnectionIndex;
  102. CComVariant* pvars = new CComVariant[1];
  103. int nConnections = m_vec.GetSize();
  104. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  105. {
  106. pT->Lock();
  107. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  108. pT->Unlock();
  109. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  110. if (pDispatch != NULL)
  111. {
  112. pvars[0] = strPage;
  113. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  114. HRESULT hResult;
  115. if (SUCCEEDED(hResult = pDispatch->Invoke(2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL)))
  116. break;
  117. }
  118. }
  119. delete[] pvars;
  120. }
  121. }
  122. };
  123. #endif