GetNumberOfEventLogRecords returns incorrect number of event logs

后端 未结 2 1465
无人及你
无人及你 2020-12-22 12:42

I have this C++ code to read the event log records

DWORD GetLogRecords(LPCWSTR wsLogFile)
{
  HANDLE hEvt = OpenEventLog(NULL, wsLogFile);
  if (hEvt==NULL)          


        
2条回答
  •  再見小時候
    2020-12-22 13:34

    For the benefit of others, the solution to this problem is that OpenEventLog doesn't accept a pathname. Instead you have to give it the source name of the event log (something like "HardwareEvents").

    If you call OpenEventLog with an invalid source name (which includes providing a pathname), then as documented it will open the Application log instead:

    If you specify a custom log and it cannot be found, the event logging service opens the Application log.

提交回复
热议问题