Replace
private delegate bool EnumResTypeProc(IntPtr hModule, string type, int param);
private bool EnumResTypeProcInstance(IntPtr hModule, string type, int param)
with
private delegate bool EnumResTypeProc(IntPtr hModule, int type, int param);
private bool EnumResTypeProcInstance(IntPtr hModule, int type, int param)
and you'll have to show
type.ToString()
I've seen comments elsewhere that suggest use of a MessageBox.Show() can "upset" callback methods. Hasn't impacted in this case, but you might be better off with
using System.Diagnostics;
...
Debug.Print(type.ToString())
[Edit]
Instead of
type.ToString()
try this
Debug.Print(type.ToString() + " " + EnumResTypeName(type));
where the new function is
private string EnumResTypeName(int Type)
{
string ret;
switch (Type)
{
case RT_ACCELERATOR:
ret = "RT_ACCELERATOR";
break;
case RT_ANICURSOR:
ret = "RT_ANICURSOR";
break;
case RT_ANIICON:
ret = "RT_ANIICON";
break;
case RT_BITMAP:
ret = "RT_BITMAP";
break;
case RT_CURSOR:
ret = "RT_CURSOR";
break;
case RT_DIALOG:
ret = "RT_DIALOG";
break;
case RT_DLGINCLUDE:
ret = "RT_DLGINCLUDE";
break;
case RT_FONT:
ret = "RT_FONT";
break;
case RT_FONTDIR:
ret = "RT_FONTDIR";
break;
case RT_GROUP_CURSOR:
ret = "RT_GROUP_CURSOR";
break;
case RT_GROUP_ICON:
ret = "RT_GROUP_ICON";
break;
case RT_HTML:
ret = "RT_HTML";
break;
case RT_ICON:
ret = "RT_ICON";
break;
case RT_MANIFEST:
ret = "RT_MANIFEST";
break;
case RT_MENU:
ret = "RT_MENU";
break;
case RT_MESSAGETABLE:
ret = "RT_MESSAGETABLE";
break;
case RT_PLUGPLAY:
ret = "RT_PLUGPLAY";
break;
case RT_RCDATA:
ret = "RT_RCDATA";
break;
case RT_STRING:
ret = "RT_STRING";
break;
case RT_VERSION:
ret = "RT_VERSION";
break;
case RT_VXD:
ret = "RT_VXD";
break;
case RT_DLGINIT:
ret = "RT_DLGINIT";
break;
case RT_TOOLBAR:
ret = "RT_TOOLBAR";
break;
default:
ret = "Unknown Type";
break;
}
return ret;
}
which uses the constants
const int RT_ACCELERATOR = 9;
const int RT_ANICURSOR = 21;
const int RT_ANIICON = 22;
const int RT_BITMAP = 2;
const int RT_CURSOR = 1;
const int RT_DIALOG = 5;
const int RT_DLGINCLUDE = 17;
const int RT_FONT = 8;
const int RT_FONTDIR = 7;
const int RT_GROUP_CURSOR = ((RT_CURSOR) + 11);
const int RT_GROUP_ICON = ((RT_ICON) + 11);
const int RT_HTML = 23;
const int RT_ICON = 3;
const int RT_MANIFEST = 24;
const int RT_MENU = 4;
const int RT_MESSAGETABLE = 11;
const int RT_PLUGPLAY = 19;
const int RT_RCDATA = 10;
const int RT_STRING = 6;
const int RT_VERSION = 16;
const int RT_VXD = 20;
const int RT_DLGINIT = 240;
const int RT_TOOLBAR = 241;
I know there's a tidier way of doing this but can't think of it at the moment.
If you actually want the names of the resources themsselves (e.g. icon names) then you need to feed the type into EnumResourceNames - have a look at this
blog[
^]