我正在尝试编写 Windows 日志事件。
我读了这个answer , 并尝试使用它但遇到了同样的问题 reported here "The description for Event ID 1 from source PLCHIDSrv cannot be found..."
我正在尝试 this solution但不知道如何在Delphi中实现这段代码
var data = new EventSourceCreationData("yourApp", "Application");
data.MessageResourceFile = pathToYourMessageFile;
EventLog.CreateEventSource(data);
最佳答案
您收到该错误是因为您没有将事件源添加到 Windows 注册表。
检查 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.
同一链接包含一个带有 C++ 代码的示例,可以轻松将其转换为 Delphi。
更新
我刚找到这篇文章 Writing an event logger with Delphi 2010
其中显示了如何将事件源添加到注册表并写入事件日志。
关于delphi - 如何使用事件源编写 Windows 日志事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26640327/