sector
asked on
An Urgent Problem With Reading Event Logger
why isn't this program returning the correct EventID code
from the logger and always return 0 even when all events in the logger are with diffrent id ?
In fact this is very much alike the sample program in the
sdk ?
#include <stdio.h>
#include "events.hpp"
#include <iostream.h>
void EventThread::RunThread()
{
HANDLE h,hEvent;
EVENTLOGRECORD *m_event;
BYTE bBuffer[MAX_PATH];
DWORD dwRead,dwNeeded,cRecords=0 ,dwThisRec ord =0;
h = OpenEventLog(NULL,"Applica tion");
if (h == NULL)
{
cout << "can't open the event logger";
}
m_event = (EVENTLOGRECORD*) &bBuffer;
hEvent = CreateEvent( LPSECURITY_ATTRIBUTES(NULL ) ,
FALSE,
FALSE,
"EventHandle");
if (!GetNumberOfEventLogRecor ds(h,&cRec ords))
cout << "error . Couldn't read or write ";
else
cout << "number of records in the system event log is :"
<< cRecords << endl;
cout << "Waiting for more events \n";
while(1)
{
NotifyChangeEventLog(h,hEv ent);
WaitForSingleObject(hEvent ,INFINITE) ;
{
ReadEventLog(h,
EVENTLOG_BACKWARDS_READ,
0,
m_event,
sizeof(EVENTLOGRECORD),
&dwRead,
&dwNeeded);
if (m_event->EventType == EVENTLOG_ERROR_TYPE )
{
switch (m_event->EventID)
{
case 4:
{
cout << " ccc was notified about bad sector on disk ";
}
default:
cout << " A Unknown event was raised ";
}
}
m_event = (EVENTLOGRECORD*) &bBuffer;
}
}
CloseEventLog(h);
}
UTL_Status EventThread::StopThread(DW ORD number)
{
// TODO
return 0;
}
void main()
{
EventThread* local = new EventThread;
local->RunThread();
}
from the logger and always return 0 even when all events in the logger are with diffrent id ?
In fact this is very much alike the sample program in the
sdk ?
#include <stdio.h>
#include "events.hpp"
#include <iostream.h>
void EventThread::RunThread()
{
HANDLE h,hEvent;
EVENTLOGRECORD *m_event;
BYTE bBuffer[MAX_PATH];
DWORD dwRead,dwNeeded,cRecords=0
h = OpenEventLog(NULL,"Applica
if (h == NULL)
{
cout << "can't open the event logger";
}
m_event = (EVENTLOGRECORD*) &bBuffer;
hEvent = CreateEvent( LPSECURITY_ATTRIBUTES(NULL
FALSE,
FALSE,
"EventHandle");
if (!GetNumberOfEventLogRecor
cout << "error . Couldn't read or write ";
else
cout << "number of records in the system event log is :"
<< cRecords << endl;
cout << "Waiting for more events \n";
while(1)
{
NotifyChangeEventLog(h,hEv
WaitForSingleObject(hEvent
{
ReadEventLog(h,
EVENTLOG_BACKWARDS_READ,
0,
m_event,
sizeof(EVENTLOGRECORD),
&dwRead,
&dwNeeded);
if (m_event->EventType == EVENTLOG_ERROR_TYPE )
{
switch (m_event->EventID)
{
case 4:
{
cout << " ccc was notified about bad sector on disk ";
}
default:
cout << " A Unknown event was raised ";
}
}
m_event = (EVENTLOGRECORD*) &bBuffer;
}
}
CloseEventLog(h);
}
UTL_Status EventThread::StopThread(DW
{
// TODO
return 0;
}
void main()
{
EventThread* local = new EventThread;
local->RunThread();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.