Windows 寫系統日誌函數

#include "windows.h"
#define SVC_ERROR    ((DWORD)0xC0020001L)
void WriteReportEvent(LPTSTR szFunction) 

HANDLE hEventSource;
LPCTSTR lpszStrings[2];
unsigned int len = sizeof(szFunction);
hEventSource = RegisterEventSource(NULL, L"Single_Event_Log");
if( NULL != hEventSource )
{
//StringCchPrintf(Buffer, 80, TEXT("%s failed with %d"), szFunction, GetLastError());
lpszStrings[0] = L"Single_Event_Log";
lpszStrings[1] = szFunction;
ReportEvent(hEventSource,        // event log handle
EVENTLOG_ERROR_TYPE, // event type
0,                   // event category
SVC_ERROR,           // event identifier
NULL,                // no security identifier
2,                   // size of lpszStrings array
0,                   // no binary data
lpszStrings,         // array of strings
NULL);               // no binary data    
DeregisterEventSource(hEventSource);
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章