Ah, save me the bother of setting up the plug-in myself, heres the source code as it stands :
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the EVENTLOG_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// EVENTLOG_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef EVENTLOG_EXPORTS
#define EVENTLOG_API __declspec(dllexport)
#else
#define EVENTLOG_API __declspec(dllimport)
#endif
#define ERROR_NONE 0
#define ERROR_ERROR 1
#define ERROR_NOEVENT -1
// This class is exported from the EventLog.dll
bool EVENTLOG_API addEventSource(LPTSTR pszLogName, // Application log or a custom log
LPTSTR pszSrcName, // event source name
LPTSTR pszMsgDLL, // path for message DLL
DWORD dwNum); // number of categories
int EVENTLOG_API reportEvent(LPSTR uncName,
LPSTR pszSrcName, // event source name
WORD eventType,
DWORD dwEventID, // event identifier
WORD wCategory, // event category
WORD cInserts, // count of insert strings
LPCTSTR *szMsg,
char *data); // insert strings
----
#include "stdafx.h"
#include "EventLog.h"
#include "stdio.h"
#include "stdlib.h"
#include "C:Program FilesMicrosoft Visual Studio .NET 2003Common7ToolsBinMessage.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This is an example of an exported variable
bool addEventSource(LPTSTR pszLogName, // Application log or a custom log
LPTSTR pszSrcName, // event source name
LPTSTR pszMsgDLL, // path for message DLL
DWORD dwNum) // number of categories
{
HKEY hk;
DWORD dwData;
TCHAR szBuf[MAX_PATH];
// Create the event source as a subkey of the log.
wsprintf(szBuf,
"SYSTEM\CurrentControlSet\Services\EventLog\%s\%s",
pszLogName, pszSrcName);
if (RegCreateKey(HKEY_LOCAL_MACHINE, szBuf, &hk))
{
return false;
}
// Set the name of the message file.
if (RegSetValueEx(hk, // subkey handle
"EventMessageFile", // value name
0, // must be zero
REG_EXPAND_SZ, // value type
(LPBYTE) pszMsgDLL, // pointer to value data
(DWORD) lstrlen(szBuf)+1)) // length of value data
{
return false;
}
// Set the supported event types.
dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
EVENTLOG_INFORMATION_TYPE;
if (RegSetValueEx(hk, // subkey handle
"TypesSupported", // value name
0, // must be zero
REG_DWORD, // value type
(LPBYTE) &dwData, // pointer to value data
sizeof(DWORD))) // length of value data
{
return false;
}
// Set the category message file and number of categories.
if (RegSetValueEx(hk, // subkey handle
"CategoryMessageFile", // value name
0, // must be zero
REG_EXPAND_SZ, // value type
(LPBYTE) pszMsgDLL, // pointer to value data
(DWORD) lstrlen(szBuf)+1)) // length of value data
{
return false;
}
if (RegSetValueEx(hk, // subkey handle
"CategoryCount", // value name
0, // must be zero
REG_DWORD, // value type
(LPBYTE) &dwNum, // pointer to value data
sizeof(DWORD))) // length of value data
{
return false;
}
RegCloseKey(hk);
return true;
}
int reportEvent(LPSTR uncName,
LPSTR pszSrcName, // event source name
WORD eventType,
DWORD dwEventID, // event identifier
WORD wCategory, // event category
WORD cInserts, // count of insert strings
LPCTSTR *szMsg,
char *data) // insert strings
{
HANDLE handle;
// Get a handle to the event log.
if ((handle = RegisterEventSource(uncName,pszSrcName))!=NULL)
{
// Report the event.
if (!ReportEvent(handle, // event log handle
eventType, // event type
wCategory, // event category
dwEventID, // event identifier
NULL, // no user security identifier
cInserts, // number of substitution strings
(data ? strlen(data) : 0), // no data
szMsg, // pointer to strings
(data ? (void *) data : NULL))) // no data
{
return (ERROR_ERROR);
}
DeregisterEventSource(handle);
return (ERROR_NONE);
}
{
char t[256];
sprintf(t,"[%d]",GetLastError());
MessageBox(NULL,t,"*",MB_OK);
}
return (ERROR_NOEVENT);
}
The first function allows you to register a DLL that would contain the description that is displayed. The reportEvent is the one that does the work.
Its really just a slightly modifed version found in the SDK help files.
Come to the UK Convention on the 23rd & 24th of October