The Micro C++ Library
micxx::Win32SDK Class Reference

Win32 SDK related functions. More...

#include <micxx/windows/Win32SDK.hxx>

Inherits micxx::traits::NonCopyable.

List of all members.

Static Public Member Functions

static void registerEventSource (const std::wstring &eventSource, const std::wstring &messageDll)
 Registers eventSource as an event source for the Event Log.
static void reportEvent (const std::wstring &eventSource, DWORD eventID, const std::wstring &functionName, unsigned long error=GetLastError(), const std::wstring &message=L"")
 Writes an entry at the end of the specified event log.
static void unregisterEventSource (const std::wstring &eventSource)
 Deletes all registry keys for eventSource from the Event Log.

Detailed Description

Win32 SDK related functions.


Member Function Documentation

static void micxx::Win32SDK::registerEventSource ( const std::wstring eventSource,
const std::wstring messageDll 
) [static]

Registers eventSource as an event source for the Event Log.

Event Viewer will not be able to map your eventIDs to message strings unless you register your eventSource (typically the name of your application) and provide a message file (typically a DLL that contains the message resources). The following steps are used to add eventSource to the registry:

  • Add eventSource as a subkey of the log.
     SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application
    
  • Set the name messageDll of the message file as a registry value of the subkey generated above. The name of the value has to be "EventMessageFile" and the type has to be REG_EXPAND_SZ.
    libmicxx builds its own DLL micxx-msg.dll from messages.mc that could be used as a message file.
  • Set the event types. There are five types of events that can be logged. For more information about the types of events that can be set, see Event Types (use the RegSetValueEx function).
  • Set the categories. You can also define the categories that can be used to organize event types (use the RegSetValueEx function).
static void micxx::Win32SDK::reportEvent ( const std::wstring eventSource,
DWORD  eventID,
const std::wstring functionName,
unsigned long  error = GetLastError(),
const std::wstring message = L"" 
) [static]

Writes an entry at the end of the specified event log.

Before you can write to the eventlog you need to add an event source to the registry.

See also:
registerEventSource(const std::wstring&, const std::wstring&)
Parameters:
eventSourceThe name of the event source as it has to be registered under the registry key
eventID
functionName
error
messageTODO: explain how to register micxx-msg.dll for serviceName
static void micxx::Win32SDK::unregisterEventSource ( const std::wstring eventSource) [static]

Deletes all registry keys for eventSource from the Event Log.


The documentation for this class was generated from the following file: