Unable to read Event Log messages Using WMI in Visual C++

  • Thread starter Thread starter GauthamArunachalam
  • Start date Start date
G

GauthamArunachalam

Guest
I am trying to read the event logs from the event user using WMI in Visual C++.

While using the Query "SELECT * FROM Win32_NTLogEvent"

Then I am using a VARIANT object to get Event Code, Event Type, and message.

While doing this I the event logs are not read fully it stops after a certain number of logs files.

Why does this happen How to resolve this??



VARIANT vtProp;

hres = pclsObj->Get(L"EventCode", 0, &vtProp, 0, 0);

wcout<< "Event Code : "<< vtProp.uintVal << " ";

VariantClear(&vtProp);


hres = pclsObj->Get(L"Message", 0, &vtProp, 0, 0);

wcout<< "Message : "<< vtProp.bstrVal << " ";

VariantClear(&vtProp);




hres = pclsObj->Get(L"RecordNumber", 0, &vtProp, 0, 0);

wcout<< "Record Number : "<< vtProp.uintVal << " ";

VariantClear(&vtProp); hres = pclsObj->Get(L"SourceName", 0, &vtProp, 0, 0); wcout<< "Source Name: " << vtProp.bstrVal << " "; VariantClear(&vtProp); hres = pclsObj->Get(L"Logfile", 0, &vtProp, 0, 0); wcout<< "Log File : " << vtProp.bstrVal << endl; VariantClear(&vtProp);

Continue reading...
 
Back
Top