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.

238 lines
9.1 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "exetst.h"
  4. #include "evtapi.h"
  5. #include "oleauto.h"
  6. /*
  7. HRESULT HrComposeEventBody(DWORD cVars, LPWSTR *rgszNames, LPWSTR *rgszTypes,
  8. VARIANT *rgvarValues, LPWSTR *pszBody);
  9. */
  10. DWORD WINAPI SubmitWorker(LPVOID pvContext)
  11. {
  12. if (PtrToUlong(pvContext) == 1)
  13. {
  14. HrSubmitEvent(L"EID 1", L"test body");
  15. HrSubmitEvent(L"EID 1", L"test body");
  16. HrSubmitEvent(L"EID 1", L"test body");
  17. HrSubmitEvent(L"EID 1", L"test body");
  18. HrSubmitEvent(L"EID 1", L"test body");
  19. }
  20. else
  21. {
  22. HrSubmitEvent(L"EID 2", L"test body");
  23. HrSubmitEvent(L"EID 2", L"test body");
  24. HrSubmitEvent(L"EID 2", L"test body");
  25. HrSubmitEvent(L"EID 2", L"test body");
  26. HrSubmitEvent(L"EID 2", L"test body");
  27. HrSubmitEvent(L"EID 2", L"test body");
  28. }
  29. return 0;
  30. }
  31. VOID WINAPI Test()
  32. {
  33. LPWSTR szSid;
  34. LPWSTR szSid2 = L"foo";
  35. HRESULT hr;
  36. (VOID)HrInitEventApi();
  37. CoInitialize(NULL);
  38. hr = HrRegisterEventSource(L"EID 1");
  39. hr = HrRegisterEventSource(L"EID 2");
  40. hr = HrRegisterEventSource(L"Testing 3");
  41. hr = HrRegisterEventSource(L"Testing 4");
  42. //LPWSTR szBody;
  43. LPWSTR rgszNames[] =
  44. {
  45. L"PropertyName1",
  46. L"PropertyName2"
  47. };
  48. LPWSTR rgszTypes[] =
  49. {
  50. L"string",
  51. L"string"
  52. };
  53. VARIANT rgvarValues[2];
  54. VariantInit(&rgvarValues[0]);
  55. VariantInit(&rgvarValues[1]);
  56. V_VT(&rgvarValues[0]) = VT_I4;
  57. V_VT(&rgvarValues[1]) = VT_I4;
  58. V_I4(&rgvarValues[0]) = 100;
  59. V_I4(&rgvarValues[1]) = 200;
  60. //hr = HrComposeEventBody(2, rgszNames, rgszTypes, rgvarValues, &szBody);
  61. DWORD csecTimeout;
  62. LPCWSTR c_rgszCallback1[] = {L"http://danielwew/upnp/foo1"};
  63. LPCWSTR c_rgszCallback2[] = {L"http://danielwew/upnp/foo2"};
  64. LPCWSTR c_rgszCallback3[] = {L"http://danielwew/upnp/foo3"};
  65. LPCWSTR c_rgszCallback4[] = {L"http://danielwew/upnp/foo4"};
  66. LPCWSTR c_rgszCallback5[] = {L"http://danielwew/upnp/foo5"};
  67. LPCWSTR c_rgszCallback6[] = {L"http://danielwew/upnp/foo6"};
  68. LPCWSTR c_rgszCallback7[] = {L"http://danielwew/upnp/foo7"};
  69. LPCWSTR c_rgszCallback8[] = {L"http://danielwew/upnp/foo8"};
  70. LPCWSTR c_rgszCallback9[] = {L"http://danielwew/upnp/foo9"};
  71. csecTimeout = 10;
  72. hr = HrAddSubscriber(L"EID 1", 0, 1, c_rgszCallback1, L"test event zero body", &csecTimeout, &szSid);
  73. csecTimeout = 20;
  74. hr = HrAddSubscriber(L"EID 1", 0, 1, c_rgszCallback2, L"test event zero body", &csecTimeout, &szSid2);
  75. csecTimeout = 30;
  76. hr = HrAddSubscriber(L"EID 1", 0, 1, c_rgszCallback3, L"test event zero body", &csecTimeout, &szSid);
  77. csecTimeout = 40;
  78. hr = HrAddSubscriber(L"EID 2", 0, 1, c_rgszCallback4, L"test event zero body", &csecTimeout, &szSid);
  79. csecTimeout = 5;
  80. hr = HrAddSubscriber(L"EID 2", 0, 1, c_rgszCallback5, L"test event zero body", &csecTimeout, &szSid);
  81. csecTimeout = 50;
  82. hr = HrAddSubscriber(L"EID 2", 0, 1, c_rgszCallback6, L"test event zero body", &csecTimeout, &szSid);
  83. csecTimeout = 60;
  84. hr = HrAddSubscriber(L"EID 1", 0, 1, c_rgszCallback7, L"test event zero body", &csecTimeout, &szSid);
  85. csecTimeout = 70;
  86. hr = HrAddSubscriber(L"EID 1", 0, 1, c_rgszCallback8, L"test event zero body", &csecTimeout, &szSid);
  87. csecTimeout = 80;
  88. hr = HrAddSubscriber(L"EID 2", 0, 1, c_rgszCallback9, L"test event zero body", &csecTimeout, &szSid);
  89. hr = HrDeregisterEventSource(L"bTesting 4");
  90. hr = HrDeregisterEventSource(L"Testing 3");
  91. hr = HrDeregisterEventSource(L"Testing 2");
  92. //Sleep(20000);
  93. csecTimeout = 100;
  94. hr = HrRenewSubscriber(L"EID 1", &csecTimeout, szSid);
  95. hr = HrRenewSubscriber(L"EID 1", &csecTimeout, szSid2);
  96. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  97. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  98. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  99. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  100. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  101. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  102. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  103. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  104. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  105. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  106. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  107. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  108. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  109. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  110. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  111. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  112. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  113. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  114. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  115. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  116. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  117. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  118. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  119. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  120. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  121. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  122. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  123. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  124. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  125. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  126. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  127. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  128. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  129. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  130. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  131. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  132. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  133. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  134. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  135. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  136. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  137. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  138. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  139. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  140. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  141. QueueUserWorkItem(SubmitWorker, (LPVOID)1, WT_EXECUTELONGFUNCTION);
  142. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  143. QueueUserWorkItem(SubmitWorker, (LPVOID)2, WT_EXECUTELONGFUNCTION);
  144. /* SubmitWorker((LPVOID)1); */
  145. /* SubmitWorker((LPVOID)1); */
  146. /* SubmitWorker((LPVOID)1); */
  147. /* SubmitWorker((LPVOID)2); */
  148. /* SubmitWorker((LPVOID)1); */
  149. /* SubmitWorker((LPVOID)2); */
  150. /* SubmitWorker((LPVOID)2); */
  151. /* SubmitWorker((LPVOID)1); */
  152. /* SubmitWorker((LPVOID)2); */
  153. /* SubmitWorker((LPVOID)1); */
  154. /* SubmitWorker((LPVOID)2); */
  155. /* SubmitWorker((LPVOID)1); */
  156. /* SubmitWorker((LPVOID)2); */
  157. /* SubmitWorker((LPVOID)1); */
  158. /* SubmitWorker((LPVOID)2); */
  159. /* SubmitWorker((LPVOID)2); */
  160. /* SubmitWorker((LPVOID)1); */
  161. /* SubmitWorker((LPVOID)1); */
  162. /* SubmitWorker((LPVOID)1); */
  163. /* SubmitWorker((LPVOID)2); */
  164. /* SubmitWorker((LPVOID)1); */
  165. /* SubmitWorker((LPVOID)2); */
  166. /* SubmitWorker((LPVOID)2); */
  167. /* SubmitWorker((LPVOID)1); */
  168. /* SubmitWorker((LPVOID)2); */
  169. /* SubmitWorker((LPVOID)1); */
  170. /* SubmitWorker((LPVOID)2); */
  171. /* SubmitWorker((LPVOID)1); */
  172. /* SubmitWorker((LPVOID)2); */
  173. /* SubmitWorker((LPVOID)1); */
  174. /* SubmitWorker((LPVOID)2); */
  175. /* SubmitWorker((LPVOID)2); */
  176. /* SubmitWorker((LPVOID)1); */
  177. /* SubmitWorker((LPVOID)1); */
  178. /* SubmitWorker((LPVOID)1); */
  179. /* SubmitWorker((LPVOID)2); */
  180. /* SubmitWorker((LPVOID)1); */
  181. /* SubmitWorker((LPVOID)2); */
  182. /* SubmitWorker((LPVOID)2); */
  183. /* SubmitWorker((LPVOID)1); */
  184. /* SubmitWorker((LPVOID)2); */
  185. /* SubmitWorker((LPVOID)1); */
  186. /* SubmitWorker((LPVOID)2); */
  187. /* SubmitWorker((LPVOID)1); */
  188. /* SubmitWorker((LPVOID)2); */
  189. /* SubmitWorker((LPVOID)1); */
  190. /* SubmitWorker((LPVOID)2); */
  191. /* SubmitWorker((LPVOID)2); */
  192. hr = HrRemoveSubscriber(L"EID 1", szSid2);
  193. hr = HrRemoveSubscriber(L"EID 1", szSid);
  194. hr = HrRemoveSubscriber(L"EID 2", szSid);
  195. OutputDebugString(L"Sleeping...\n");
  196. Sleep(20000);
  197. hr = HrDeregisterEventSource(L"EID 1");
  198. hr = HrDeregisterEventSource(L"EID 2");
  199. DeInitEventApi();
  200. CoUninitialize();
  201. Sleep(2000);
  202. OutputDebugString(L"Exiting...\n");
  203. }