SourceName As String,
[ComputerName] As String,
[MessageFileName] As String,
[OverWriteMessageFileEntry] As Boolean
[in] String SourceName
Event Source Name to be registered. This refers to the name of the application logging the events.
[in] String ComputerName
Computer Name where the event source is to be registered. This parameter is optional.
[in] String MessageFileName
Name of the message (resource) file. This parameter is optional.
Flag indicating whether to overwrite the message file entry or not. This parameter is optional.
Before logging an event to the Windows event log, one must create a registry subkey under 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application'
This subkey is the event source name used while registering the event source. The RegisterCurrentEventSource method creates the required subkey on the given computer.
When you are registering the event source name for the first time, a registry key is created for that event source name. At that time, the name of the message DLL used by this event source name is also written to the registry. So, the third parameter (MessageFileName) is compulsory when you first register the event source name. It is optional for subsequent calls.
Dim EventLog As IEventLogger
'Get the interface. 'DirectScript.EventLogger.1'is the ProgId of 'the Event Logger component.
Set EventLog = CreateObject ("DirectScript.EventLogger.1")
'Call the RegisterCurrentEventSource method
EventLog.RegisterCurrentEventSource "TestLog", "\\MOON", TestMsgFile.DLL", True