Attila Kovacs 629 Posted January 17, 2022 in the Vcl.SvcMgr.pas / procedure TServiceApplication.Run; there are these two lines: if StartThread.ReturnValue <> 0 then FEventLogger.LogMessage(SysErrorMessage(StartThread.ReturnValue)); where LogMessage (windows ReportEvent()) gets a string parameter containing an error message and having 3 other parameters filled with default values: EventType=1, Category=0, ID=0. Now, every time this LogMessage is called, in the Event Logs I see an entry with ID=0 and the message is not the one passed to this method but the translated error message (to the windows' current language) of the ID=0. (Or some similar mechanism which I'm not aware of.) Like I'm having always: "Der Vorgang wurde erfolgreich beendet." ID = 0. But if I'm also passing the error code to LogMessage, like: FEventLogger.LogMessage(SysErrorMessage(StartThread.ReturnValue), 1, 0, StartThread.ReturnValue); then in the event viewer are the right messages. Also, the message parameter (the first parameter) will be inserted in those messages if there is a placeholder for that. Did something change since Windows NT or ist it a longstanding bug or do I miss something? Share this post Link to post
Remy Lebeau 1397 Posted January 18, 2022 14 hours ago, Attila Kovacs said: Now, every time this LogMessage is called, in the Event Logs I see an entry with ID=0 and the message is not the one passed to this method but the translated error message (to the windows' current language) of the ID=0. (Or some similar mechanism which I'm not aware of.) I have been using TService for many years, and I have never experienced what you describe. Whenever I use LogMessage() (which, I admit is very rare, as I prefer my own logging), the passed string message is displayed as-is in the event log (prefixed with "The description for Event ID 0 ... cannot be found" if I don't include a proper message table resource that maps ID 0 to '%s'). 14 hours ago, Attila Kovacs said: Did something change since Windows NT or ist it a longstanding bug or do I miss something? No. The behavior of the ReportEvent() API has not changed over the years. Share this post Link to post
Attila Kovacs 629 Posted January 18, 2022 I believe you but I'm not dreaming. Share this post Link to post
Attila Kovacs 629 Posted January 18, 2022 6 minutes ago, Remy Lebeau said: if I don't include a proper message table resource that maps ID 0 btw. is there any default table provided by delphi? Share this post Link to post
Remy Lebeau 1397 Posted January 18, 2022 (edited) 16 minutes ago, Attila Kovacs said: btw. is there any default table provided by delphi? No, there is not. I create my own table manually, using a combination of Microsoft's Message Compiler and XN Resource Editor (to tweak the output from mc.exe) to produce a .res file that I then link into my project Edited January 18, 2022 by Remy Lebeau 1 Share this post Link to post