We would like to list the contents (key/value pairs) of messages embedded in a resource-only library (DLL)
The resource library is defined as specified in MSDN.
mc -s EventLogMsgs.mc
rc EventLogMsgs.rc
link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res
A sample EventLogMsgs.mc may be:
; // - Event categories -
; // Categories must be numbered consecutively starting at 1.
; // ********************************************************
MessageId=0x1
Severity=Success
SymbolicName=INSTALL_CATEGORY
Language=English
Installation
.
MessageId=0x2
Severity=Success
SymbolicName=QUERY_CATEGORY
Language=English
Database Query
.
...
We tried to use EnumResourceTypes() Win32 API as following:
...
HMODULE hMod=NULL;
hMod = LoadLibraryA( "C:\\temp\\EventLogMsgs.dll" );
if (hMod != NULL)
{
EnumResourceTypes( hMod, (ENUMRESTYPEPROC)TypesCallback, 0) ;
FreeLibrary(hMod);
}
...
BOOL WINAPI TypesCallback( HMODULE hModule, LPTSTR lpType, LONG lParam )
{
char buffer[100];
if ((ULONG)lpType & 0xFFFF0000)
sprintf( buffer, "%s\n", lpType);
else
sprintf(buffer, "%u\n", (USHORT)lpType);
cout << "Type: " << buffer << std::endl;
EnumResourceNames( hModule, lpType, (ENUMRESNAMEPROC)NamesCallback, 0 );
return true;
}
BOOL WINAPI NamesCallback( HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG lParam )
{
char buffer[100];
if ((ULONG)lpName & 0xFFFF0000)
sprintf(buffer,"%s\n", lpName);
else
sprintf(buffer, "%u\n",(USHORT)lpName);
cout << "Name: " << buffer << std::endl;
return true;
}
The result is a high level listing of the resource types and their "names/identifiers", e.g.,
...
Type: 11
Name: 1
Type: 16
Name: 1
Type: 24
Name: 2
...
11 (RT_MESSAGETABLE) is the message table resource type (See all resource types)
Ideally we would want to list ALL the actual messages' symbolic names and identifiers in the resource library.
Thanks