There are APIs to iterate over all the resources and look at the IDs and types and values.
For example, see EnumResourceTypes and EnumResourceNames.
If you could be a little more specific about what you need, I might be able to suggest
some approaches.
Note that MAKEINTRESOURCE does *not* convert a resource name to a resource ID; it takes an
integer resource ID and lets you pass it as a string argument. The way LoadResource works
is if the argument is in the range 1..65535, it looks up the resource ID by doing integer
compare with the value; if it is >65535, it assumes it is a string pointer and looks up
the resource ID by doing a string compare with the value pointed to. So it doesn't
actually "convert" anything.
The macro IS_INTRESOURCE is used to detect if the value is a resource or a pointer; it is
#define IS_INTRESOURCE(_r) (((ULONG_PTR)(_r) >> 16) == 0)
so you can do this yourself if you want:
void SomeFunctionOfMine(LPTSTR p)
{
if(IS_INTRESOURCE(p))
{ /* int */
int value = (int)p;
... do things with the integer
} /* int */
else
{ /* string */
LPCTSTR value = p;
.. do things with string
} /* string */
Now suppose you have, in your resource.h file, something of the form:
#define IDC_WHATEVER 211
appears in resource.h; if you want to load the resource, you have to do
HRSRC FindResource(module, MAKEINTRESOURCE(211), type)
but you don't actually write
MAKEINTRESOURCE(211)
you write
MAKEINTRESOURCE(IDC_WHATEVER)
which the *preprocessor* converts to
MAKEINTRESOURCE(211)
The types work the same way. There are predefined types like RC_DIALOG, where RC_DIALOG
is described as
#define RT_DIALOG MAKEINTRESOURCE(5)
MAKEINTRESOURCE itself is a trivial macro, simplistically,
#define MAKEINTRESOURCE(x) ((LPTSTR)(ULONG_PTR)(WORD)(x))
However, there is no *possible* way to say, for example
CString ResourceToString(LPCTSTR p)
{
if(IS_INTRESOURCE(p))
return ...something that evaluates to "IDC_WHATEVER";
else
return CString(p);
}
so that if you were to call it with
ResourceToString(MAKEINTRESOURCE(IDC_WHATEVER))
that would return "IDC_WHATEVER" as a string value.
That said, you can do certain things like
#define ResourceToString(x) _T(#x)
which means if you write
ResourceToString(IDC_WHATEVER)
you get the string "IDC_WHATEVER"
but that's because all we did was say "convert the input argument to a string and return
that string". So suppose we had
#define IDC_WHATEVER 211
#define IDC_THING 212
if you called the above macro
ResourceToString(IDC_WHATEVER + 1)
you would *not* get "IDC_THING", you would get "IDC_WHATEVER + 1".
Does any of this help?
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm