FireEvent Example (Visual C++)

   Applies To

This example shows what a call to FireEvent looks like. Refer to ISystemDebugEventFire Example (Visual C++) to see the constant declarations and object creation code, as well as to see this code in a form you can run with minor modifications.

// Prepare to generate an event.
// Declare a byteArray to hold binary data; event data can be one of five
// different types, including binary data; all types are shown.
BYTE byteArray[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a";

// Event data is passed in arrays of parameter names (keys) and values.
// This array holds the parameter names. It is sized at 5 to show the
// five different types of event data you can pass.
// Standard event parameters (such as cVSAStandardParameterSourceHandle)
// are defined in vaevt.h
#define MAXPARAMS 5
DWORD rgKeys[ MAXPARAMS ] = {
   cVSAStandardParameterCorrelationID,      // System-defined parameter
   (DWORD) L"First custom parameter",      // 3 custom parameters
   (DWORD) L"Second custom parameter",
   (DWORD) L"Third custom parameter",
   cVSAStandardParameterSourceHandle };   // Another system-defined
                                          // parameter

// This array holds the parameter values.
DWORD rgValues[ MAXPARAMS ] = {
   (DWORD) L"This is a unicode string",
   (DWORD) "This is an ANSI string",
   (DWORD) &SAMPLE_GUID_PARAMETER,
   0xFFFFFFFF,
   (DWORD) byteArray };

// Remember to specify cVSAParameterKeyString for all custom parameters
// and to specify the length for all BYTE array data.
DWORD rgTypes[ MAXPARAMS ] = { 
   cVSAParameterValueUnicodeString,
   cVSAParameterKeyString | cVSAParameterValueANSIString,
   cVSAParameterKeyString | cVSAParameterValueGUID,
   cVSAParameterKeyString | cVSAParameterValueDWORD,
   cVSAParameterValueBYTEArray | ( cVSAParameterValueLengthMask &
sizeof(byteArray) ) };

// Generate the event.
// SAMPLE_EVENT_GUID is the GUID of the registered event to generate
void SampleFireEvent()
{
   pIEC->FireEvent( SAMPLE_EVENT_GUID, MAXPARAMS, rgKeys, rgValues,
rgTypes, 0, 0, 
      cVSAEventDefaultSource | cVSAEventDefaultTarget );
}