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.

39 lines
897 B

  1. #include "stdafx.h"
  2. #include "trace.h"
  3. void CTrace::TraceEvent(LPCTSTR pFormat, ...)
  4. {
  5. ATLTRACE(_T("CTrace::TraceEvent\n"));
  6. m_pcs->ReadLock();
  7. __try {
  8. TCHAR chMsg[256];
  9. HANDLE hEventSource;
  10. LPTSTR lpszStrings[1];
  11. va_list pArg;
  12. va_start(pArg, pFormat);
  13. _vstprintf(chMsg, pFormat, pArg);
  14. va_end(pArg);
  15. lpszStrings[0] = chMsg;
  16. /* Get a handle to use with ReportEvent(). */
  17. hEventSource = RegisterEventSource(NULL, m_szSourceName);
  18. if (hEventSource != NULL)
  19. {
  20. /* Write to event log. */
  21. ReportEvent(hEventSource, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (LPCTSTR*) &lpszStrings[0], NULL);
  22. DeregisterEventSource(hEventSource);
  23. }
  24. }
  25. __except ( EXCEPTION_EXECUTE_HANDLER, 1 ) {
  26. _ASSERTE( false );
  27. }
  28. m_pcs->ReadUnlock();
  29. }