diff --git a/EventLogging.cpp b/EventLogging.cpp new file mode 100644 index 0000000..3814a5c --- /dev/null +++ b/EventLogging.cpp @@ -0,0 +1,55 @@ +// EventLogging.cpp: implementation of the EventLogging class. +// +////////////////////////////////////////////////////////////////////// + +#include "EventLogging.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +EventLogging::EventLogging() +//******************************************************************************* +// Default Constructor is used register the event source +//****************************************************************************** +{ + // returns a handle that links the source to the registry + this->m_hEventLinker = RegisterEventSource(NULL,L"MacType"); + +} + +EventLogging::~EventLogging() +//******************************************************************************* +// Destructor is used deregister the event source +//******************************************************************************* +{ + // Releases the handle to the registry + DeregisterEventSource(m_hEventLinker); +} + + + +void EventLogging::LogIt(WORD CategoryID, DWORD EventID, LPCTSTR ArrayOfStrings[], + UINT NumOfArrayStr,LPVOID RawData,DWORD RawDataSize) +//******************************************************************************* +// Function is used to log the event into the .evt file. +// Input: CategoryID is the events category classification +// EventID is the events event classification +// ArrayOfStrings is an array of pointers to strings that are passed for additional information gathering +// NumOfArrayStr is the number of of strings in ArrayOfStrings +// RawData is a void pointer to hold additional raw data for event reporting +// RawDataSize is the size of RawData in bytes +//******************************************************************************* +{ + + // Writes data to the event log + ReportEvent(m_hEventLinker,EVENTLOG_INFORMATION_TYPE,CategoryID, + EventID,NULL,NumOfArrayStr,RawDataSize,ArrayOfStrings,RawData); + +} \ No newline at end of file diff --git a/EventLogging.h b/EventLogging.h new file mode 100644 index 0000000..f5370ca --- /dev/null +++ b/EventLogging.h @@ -0,0 +1,27 @@ +// EventLogging.h: interface for the EventLogging class. +// +////////////////////////////////////////////////////////////////////// +#include "common.h" +#if !defined(AFX_EVENTLOGGING_H__4AED0DCC_4C48_4312_BA6F_E6B90AC47F32__INCLUDED_) +#define AFX_EVENTLOGGING_H__4AED0DCC_4C48_4312_BA6F_E6B90AC47F32__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class EventLogging +{ +public: + EventLogging(); + virtual ~EventLogging(); + + // Wrapper for ReportEvent that take care of Handle and EventType + virtual void LogIt(WORD CategoryID, DWORD EventID, LPCTSTR ArrayOfStrings[] = NULL, + UINT NumOfArrayStr = 0,LPVOID RawData = NULL,DWORD RawDataSize = 0); + // data member to contain handle to registry + HANDLE m_hEventLinker; + + +}; + +#endif // !defined(AFX_EVENTLOGGING_H__4AED0DCC_4C48_4312_BA6F_E6B90AC47F32__INCLUDED_)