mirror of https://github.com/tongzx/nt5src
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
39 lines
897 B
#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();
|
|
}
|