Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting event log in c++
    primarykey
    data
    text
    <p>I am trying to get system event log in c++ by using following code , <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb427356%28v=vs.85%29.aspx" rel="nofollow">Querying for Event Information</a>.But for some condition i am getting ,Invalid event ID.Value of event ID is <strong>1073742727</strong>.Which is wrong.</p> <p>My code is look like following ,</p> <pre><code>EVENTLOG_FULL_INFORMATION evntLogInfo; DWORD dwByteRequd,cbSize=0,dwBytesToRead=MAX_RECORD_BUFFER_SIZE,dwBytesRead,dwMinimumBytesNeeded,numRecord; PBYTE pBuffer,currentData,endRecord; HANDLE eventHandle=OpenEventLog(NULL,"Application"); if(eventHandle==INVALID_HANDLE_VALUE) cout&lt;&lt;"\nError "&lt;&lt;GetLastError(); else { pBuffer=(PBYTE)malloc(MAX_RECORD_BUFFER_SIZE); if(pBuffer==NULL) { cout&lt;&lt;"\nNot enough memory"; CloseEventLog(eventHandle); } else { //GetEventLogInformation(eventHandle,EVENTLOG_FULL_INFO,&amp;pBuffer,cbSize,&amp;dwByteRequd); ReadEventLog(eventHandle,EVENTLOG_SEQUENTIAL_READ|EVENTLOG_FORWARDS_READ,0,pBuffer,dwBytesToRead,&amp;dwBytesRead,&amp;dwMinimumBytesNeeded); if(GetLastError()==ERROR_INSUFFICIENT_BUFFER ) { pBuffer=(PBYTE)realloc(pBuffer,dwMinimumBytesNeeded); if(pBuffer==NULL) { cout&lt;&lt;GetLastError(); CloseEventLog(eventHandle); } else { dwBytesToRead=dwMinimumBytesNeeded; ReadEventLog(eventHandle,EVENTLOG_SEQUENTIAL_READ|EVENTLOG_FORWARDS_READ,0,pBuffer,dwBytesToRead,&amp;dwBytesRead,&amp;dwMinimumBytesNeeded); } } GetNumberOfEventLogRecords(eventHandle,&amp;numRecord); cout&lt;&lt;numRecord&lt;&lt;"\n"; endRecord=pBuffer+dwBytesToRead; while(pBuffer&lt;endRecord) { currentData=pBuffer; PEVENTLOGRECORD TempVar = (PEVENTLOGRECORD)currentData; cout&lt;&lt;((PEVENTLOGRECORD)currentData)-&gt;EventID&lt;&lt;"\t"; cout&lt;&lt;((PEVENTLOGRECORD)currentData)-&gt;EventType&lt;&lt;"\t"; cout&lt;&lt;((PEVENTLOGRECORD)currentData)-&gt;Length&lt;&lt;"\n"; // DWOR error=GetLastError(); } } } </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload