Message Catalog and FormatMessage()? (Help Request) 
Author Message
 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



Tue, 06 May 2003 03:00:00 GMT  
 Message Catalog and FormatMessage()? (Help Request)
Scott,

 > I've got a difficult time believing the same handle is always
 > being returned on a dozen runs.

Why? If the preferred load address for the DLL is available, it will
always get loaded there. The load address serves as the "handle" to the
module.

Regarding FormatMessage(), if it returns zero, what does GetLastError(0
say?

--

Cheers,
Felix.

If you post a reply, kindly refrain from emailing it, too.

No anti-spam address here. Just one comment: IN YOUR FACE!



Wed, 07 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Request catalogs via the Internet

2. Retrieving message from message table with FormatMessage( )

3. Retrieving message from message table with FormatMessage( )

4. Message Catalog

5. Posix Message Catalogs

6. FormatMessage() With Message Inserts

7. HELP: Intercepting HTTP Request, Showing Login Page, and Continuing with Original Request

8. Create Html Help, WinHelp, catalogs and manuals with ease, on Web

9. Help with FormatMessage()

10. Help with FormatMessage()

11. FormatMessage + On Line Help

12. Help with FormatMessage()

 

 
Powered by phpBB® Forum Software