windows-nt/Source/XPSP1/NT/sdktools/debuggers/excepmon/emsvc/trace.cpp

40 lines
897 B
C++
Raw Normal View History

2020-09-26 03:20:57 -05:00
#include "stdafx.h"
#include "trace.h"
void CTrace::TraceEvent(LPCTSTR pFormat, ...)
{
ATLTRACE(_T("CTrace::TraceEvent\n"));
m_pcs->ReadLock();
__try {
TCHAR chMsg[256];
HANDLE hEventSource;
LPTSTR lpszStrings[1];
va_list pArg;
va_start(pArg, pFormat);
_vstprintf(chMsg, pFormat, pArg);
va_end(pArg);
lpszStrings[0] = chMsg;
/* Get a handle to use with ReportEvent(). */
hEventSource = RegisterEventSource(NULL, m_szSourceName);
if (hEventSource != NULL)
{
/* Write to event log. */
ReportEvent(hEventSource, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (LPCTSTR*) &lpszStrings[0], NULL);
DeregisterEventSource(hEventSource);
}
}
__except ( EXCEPTION_EXECUTE_HANDLER, 1 ) {
_ASSERTE( false );
}
m_pcs->ReadUnlock();
}