Retrieving message from message table with FormatMessage( ) 
Author Message
 Retrieving message from message table with FormatMessage( )

Does anyone know why I am getting error code 317
(The system cannot find message text for message
number 0x%1 in the message file for %2. ) when
trying to read NT event log message files.  It
works OK when I read my own message file. But
any other message file, I would get 317.

My FormatMessage( ) looks like this:

CString& NTMessageDLL::Read( DWORD messageID )
{
    DWORD    bytesRead    = 0;

    DWORD    format = FORMAT_MESSAGE_ARGUMENT_ARRAY  |
                      FORMAT_MESSAGE_ALLOCATE_BUFFER |
                      FORMAT_MESSAGE_FROM_HMODULE;

    TCHAR*            buffer       = NULL;
    CString           replacementString[5] = { _T("%1"), _T("%2"), _T("%3"),
_T("%4") };
    if ( _handle != NULL )
       bytesRead = FormatMessage( format, _handle, messageID, 0,
( LPTSTR )&buffer,
       0, ( va_list* )replacementString );

    _tprintf( _T(" NTMessageDLL::Read( ) %d:%s bytesRead:%d error:%d\n"),
messageID, buffer, bytesRead,   GetLastError( ));
    return ( CString( buffer ));

Quote:
}

Thanks.

Min



Wed, 29 Nov 2000 03:00:00 GMT  
 Retrieving message from message table with FormatMessage( )



Quote:
> Does anyone know why I am getting error code 317
> (The system cannot find message text for message
> number 0x%1 in the message file for %2. ) when
> trying to read NT event log message files.  It
> works OK when I read my own message file. But
> any other message file, I would get 317.

<snip>

I don't think that...

Quote:
>     CString           replacementString[5] = { _T("%1"), _T("%2"),

_T("%3"), _T("%4") };

is the same as LPCTSTR replacementString[5] - the array FormatMessage
expects is of pointers and I don't suppose it calls the (LPCTSTR) operator
if you pass it an array of CStrings.  Try an array of LPTSTRs instead.
Hope this helps.

Phil



Fri, 01 Dec 2000 03:00:00 GMT  
 Retrieving message from message table with FormatMessage( )

I tried LPCTSTR. It gave the same result.

As a matter of fact, this code not only works with my own
message DLL generated from MC file. It also works with
some of the message DLLs used by the eventlog, such as
RemoteAccess's WINNT/System32/rasmsg.dll. But it doesn't
work with every message DLL.

While browsing the NT-Perl mail list, some people mentioned
ParameterMessageFile. Does this have anything to do with this?

With the ReadEventLog( ), we can get everything from a remote
machine's eventlog except the Description. However, description
is the most important for users. I understand for NLS and
dynamic error management, the message file will exist
independently.  However, to install an agent on every target
machine just to read the message file seems awkard.

There are some software such as EventAdmin that don't require
the server piece running on the target machine.  I wonder
how they did.  Is there any unpublished APIs? :-)

Thanks.

Min

Quote:



>> Does anyone know why I am getting error code 317
>> (The system cannot find message text for message
>> number 0x%1 in the message file for %2. ) when
>> trying to read NT event log message files.  It
>> works OK when I read my own message file. But
>> any other message file, I would get 317.

><snip>

>I don't think that...
>>     CString           replacementString[5] = { _T("%1"), _T("%2"),
>_T("%3"), _T("%4") };

>is the same as LPCTSTR replacementString[5] - the array FormatMessage
>expects is of pointers and I don't suppose it calls the (LPCTSTR) operator
>if you pass it an array of CStrings.  Try an array of LPTSTRs instead.
>Hope this helps.

>Phil



Mon, 04 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Retrieving message from message table with FormatMessage( )

2. FormatMessage() With Message Inserts

3. Message Catalog and FormatMessage()? (Help Request)

4. Message Table vs String Table

5. How to retrieve windows message parameteres(in MFC)

6. Retrieve key messages

7. OnUpdate message retrieved too late

8. retrieving user messages

9. Message table

10. Multiple Messages Tables

11. Need help with compiling a message table for event log

12. Load string from message table ???

 

 
Powered by phpBB® Forum Software