beckhoff — 10.3.2 Console Application - Read logged events via DCOM

Samples 2. Choose 'dialog based' as application type. 3. Right click on the dialog and choose 'Insert ActiveX Control' 4. Choose the 'BECKHOFF TcEventView Class' 10.3.2 Console Application - Read logged events via DCOM The following example shows how to view a list of logged messages in C++. 1. Create a standard Console Application. 2. Add this Sourcecode:

if( SUCCEEDED(CoInitialize( 0 )) ) { ITcEventLogPtr spEventLogger; ITcEnumEventsPtr spEnumEvts; ITcEventPtr spEvent; IDispatchPtr spDisp; if( SUCCEEDED( spEventLogger.CreateInstance(CLSID_TcEventLog)) { spEnumEvts =spEventLogger->EnumLoggedEvents(); if(spEnumEvts) { while(spEnumEvts->Next(1, &spDisp) == 1 ) { spEvent = spDisp; spEvent->GetMsgString(1033); printf( "Event %i; Source %i\n Message = %s\n",spEvent->GetId(), spEvent- >GetSrcId(),(char*)spEvent->GetMsgString(1033) ); spDisp = NULL; } } } spEnumEvts = NULL; spEvent = NULL; spEventLogger = NULL; CoUninitialize(); } The Program uses the ITcEnumEvents Interface to enumerate logged messages.

The text of all logged messages is shown in the Console. return 0; TcEventLogger 191 Version: 1.1 Language / IDE Source code Visual Studio 6 C++ Sample01.zip (in preparation)