-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8508d8d
commit f175114
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_) |