Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I writing windows log event with event source

I'm trying to write an windows log event.

I read this answer, and tried to use it but had the same problem reported here "The description for Event ID 1 from source PLCHIDSrv cannot be found..."

I'm trying this solution but do not know how to implement this code in Delphi

var data = new EventSourceCreationData("yourApp", "Application");
data.MessageResourceFile = pathToYourMessageFile;
EventLog.CreateEventSource(data);
like image 856
MarcosK Avatar asked Jan 29 '26 21:01

MarcosK


1 Answers

You are receiving that error because you are not adding the event source to the Windows Registry.

Check the MSDN Documentation :

You can use the default Application log without adding an event source to the registry. However, Event Viewer will not be able to map your event identifier codes to message strings unless you register your event source and provide a message file.

The same link contains a sample with a C++ Code , which can be easily translated to Delphi.

UPDATE

I just found this article Writing an event logger with Delphi 2010 which shows how add an event source to the registry and write to the event log.

like image 59
RRUZ Avatar answered Feb 01 '26 12:02

RRUZ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!