Function EventLogWriteStr() Foundation

Appends a string to the operating system's event log.

Syntax
EventLogWriteStr( <cMessage>, <cLogSource>, ;
                 [<cMachineName>], [<nEventType>] ) --> lSuccess
Parameters
<cMessage>
A character string with the message to be appended to the log file.
Due to operating system dependent restrictions, only 32 kB of information can be appended to a log at once.
<cLogSource>
Name of the source that creates the log message. Before a log source can be used, it must be made known to the operating system. When the log is viewed with the operating system's log viewer, the name of the source is displayed in a separate column. See description below for details.
<cMachineName>
The name of the machine whose log becomes updated. When a log of the local machine is used, the value NIL can be passed for <cMachineName>.
<nEventType>
This parameter indicates the log message type. It influences the icon shown in front of the message when it is displayed by the operating system's log viewer. #define constants from the file OS.CH must be used:
Constants for log message types.
Constant Description
LOG_SUCCESS Success message
LOG_ERROR_TYPE Error message
LOG_WARNING_TYPE Warning message
LOG_INFORMATION_TYPE *) Informational message
LOG_AUDIT_SUCCESS Success on audit event
LOG_AUDIT_FAILURE Error on audit event
  1. default
Return

The function returns .T. (true) when the string is successfully appended to the log file. Otherwise .F. (false) is returned.

Description

The function can be used to write information to the system event log on WindowsNT, Windows 2000 and Windows XP. Event logs are not supported by Windows 95, Windows 98 and Windows ME.

Prior using this function, the log source must be made known to the operating system by modifying the registry. For this proceed as follows: Create an empty text file (with notepad.exe for example) and paste the following lines into it. Replace <installation directory> with the path of your Xbase++ installation:

1 REGEDIT4 
2 
3 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ 
4   Eventlog\Application\TestLog] 
5 "EventMessageFile"=<installation directory>"\\lib\\ASLogResource.dll" 
6 "TypesSupported"=dword:00000015 

In line 4, the name of the log source is defined (TestLog). In line 5 the resource dll must be entered. Please modify the path to the resource dll according to your Xbase++ installation.

Save the file to disk and import it with the operating systems regedit.exe application to the registry.

After this is done a messge <cMessage> can be appended to the application log and the string TestLog is entered to the Source column with following lines of code:

EventLogWriteStr( "Message String", "TestLog"  ) 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.