API question - dealing with messages
-
Hi! I've posted this question in the "Suggestion" board, because there is no API discussion, and was advised to post it to C++ board. Sorry for long story. I've created the NT service that in the case of error not only register event in the Application EventLog, but also may send this event by mail to the predefined SMTP address. In the configuration applet for this service I'd like to let the user to select, what events he/she wants to receive in mail. So I'd like to extract the list of events from the event source, registered in HKLM\SYSTEM\CurrentControlSet\Services\Eventlog\Application\EventMessageFile. I can extract the single event with FormatMessage, if I know the ID. But if I don't? The question is: How I can enumerate the events in the EventMessageFile? Sure I can do it "manualy" analyzing the message file structure. But I prefer something more safe in the case, they in MS will change the message file structure. And using API (if there is any) will save me from unskilled labour. I don't afraid to do such a work, but if I can avoid it ... Thanks in advance. Regards, Gennady
-
Hi! I've posted this question in the "Suggestion" board, because there is no API discussion, and was advised to post it to C++ board. Sorry for long story. I've created the NT service that in the case of error not only register event in the Application EventLog, but also may send this event by mail to the predefined SMTP address. In the configuration applet for this service I'd like to let the user to select, what events he/she wants to receive in mail. So I'd like to extract the list of events from the event source, registered in HKLM\SYSTEM\CurrentControlSet\Services\Eventlog\Application\EventMessageFile. I can extract the single event with FormatMessage, if I know the ID. But if I don't? The question is: How I can enumerate the events in the EventMessageFile? Sure I can do it "manualy" analyzing the message file structure. But I prefer something more safe in the case, they in MS will change the message file structure. And using API (if there is any) will save me from unskilled labour. I don't afraid to do such a work, but if I can avoid it ... Thanks in advance. Regards, Gennady
Message table is normal Win32 resource, so you need to load message file using LoadLibraryEx() with LOAD_LIBRARY_AS_DATAFILE flag. Then, use EnumResourceXXX/FindResource/LoadResource functions to retrieve MESSAGE_RESOURCE_XXX structures. Hope that helps. Tomasz Sowinski -- http://www.shooltz.com.pl
-
Message table is normal Win32 resource, so you need to load message file using LoadLibraryEx() with LOAD_LIBRARY_AS_DATAFILE flag. Then, use EnumResourceXXX/FindResource/LoadResource functions to retrieve MESSAGE_RESOURCE_XXX structures. Hope that helps. Tomasz Sowinski -- http://www.shooltz.com.pl
Thanks ! EnumResourceNames is exactly what I looked for. Don't know why I couldn't find it myself - may be search expression was wrong. Thank you once more. Regards, Gennady