The RegisterEventSource function returns the hEventLog of ReportEvent .
And According to The Eventlog Key Topic, You can Custom the File registry value Which specifies Fully qualified path to the file where each event log is stored in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\YourEventProvider registry key.
Unit test module that writes to windows event viewer by writing to a file
I want to unit test my code that writes to windows event log. I use the ReportEvent function. Is there a way to make the function write to a file instead of windows eventviewer? I tried providing a file handle as the first parameter but it returned with invalid handle error. How can I test my code?
int res = ReportEvent( pfile, EVENTLOG_INFORMATION_TYPE, 0, 256, NULL, static_cast<WORD>(eventDetails.size()), 0, &eventDetails[0], NULL );
Windows development | Windows API - Win32
Developer technologies | C++
1 answer
Sort by: Most helpful
-
Xiaopo Yang - MSFT 12,736 Reputation points Microsoft External Staff
2021-07-16T08:26:01.54+00:00