This base class is the basis for all variable length events. Derive from this class to create your own custom events. For a list of all members of this type, see CVariableLengthBaseEvent Members. CVariableLengthBaseEvent [C++]
class CVariableLengthBaseEvent
Example[C++]
class CEventVariableLen:
public CVariableLengthBaseEvent<EVENT_VARIABLE_LEN, &MY_VARIABLE_LEN_EVENTCLASS>
{
public:
CEventVariableLen(LPCWSTR lpszString1, LPCWSTR lpszString2,
LPCWSTR lpszString3)
{
// Firstly, you must calculate the size of event structure
int nSize = sizeof(_EventDataType) +
StringSizeInBytes(lpszString1) +
StringSizeInBytes(lpszString2) +
StringSizeInBytes(lpszString3);
// Initialize the event. This creates the structure in m_pData and
// sets up standard event details, like the event type, the event
// guid, etc...
InitEventData(nSize, EVENT_TRACE_TYPE_INFO);
//
// Set your event data
//
m_pData->Data.dwProcessID = GetCurrentProcessId();
m_pData->Data.dwThreadID = GetCurrentThreadId();
// Notice how the string offsets are calculated.
CopyString(m_pData->Data.szStringData, lpszString1);
CopyString(LPWSTR(int(m_pData->Data.szStringData) +
StringSizeInBytes(lpszString1)), lpszString2);
CopyString(LPWSTR(int(m_pData->Data.szStringData) +
StringSizeInBytes(lpszString1) +
StringSizeInBytes(lpszString2)), lpszString3);
// Again, if you need to, you can set specific values in the event
// header through m_pData->Header.
//
// Set text equivelent of the event for verbose debug output. You
// don't have to do this, but it might be handy to do so?
//
SetTextEvent("Process ID = 0x%X, Thread ID = 0x%X, String1 = '%ls',"\
"String2 = '%ls', String3 = '%ls'\n", m_pData->Data.dwProcessID,
m_pData->Data.dwThreadID, lpszString1, lpszString2, lpszString3);
}
};
RequirementsPlatforms: Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family Header: Declared in WMIEventTracing.h
See AlsoCVariableLengthBaseEvent Members | CTraceEvent Members | CTraceController Members | CBaseEvent Members |
Contact Me | Developing WMI Solutions | Gwyn Cole's Developer Blog | Legal |
© 2003 Content by Gwyn Cole. All rights reserved. |