
Message Catalog and FormatMessage()? (Help Request)
Hey all. I've got an issue where I need to take a va_list and
ultimately sent it to the EventLog via ReportEvent(). Of course,
ReportEvent() doesn't accept a va_list, nor is there a way to step
through a va_list without some predetermined means of knowing when
you're at the last param, nor is there an way to determine type without
a format specifier of some sort.
The format specifier does exist, however, it's in an NT Message catalog,
which is in the registry properly. FormatMessage() _seems_ to be the
right tool for the job, eg:
HMODULE hLog = LoadLibrary(mypath);
errCode = FormatMessage(FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_ALLOCATE_BUFFER,
hLog,
EV_LOG_TEST,
0,
buffer2,
0,
&ap);
In this scenario, I already have a HANDLE to the particular Event
Source, but am doing the LoadLibrary call explictly anyway. hLog
_ALWAYS_ seems to be 0x1000000..while the API spec says NULL is returned
on error, I've got a difficult time believing the same handle is always
being returned on a dozen runs. Is this a valid return here?
The FormatMessage() call does NO allocation of the buffer, so it would
seem it's unable to locate the proper catalog or ID.
So, the question becomes-
Given the fact I must convert a va_list to a proper format to hand off
to ReportEvent(), is there a better solution? Or will the above
approach work and I'm missing something?
SW