How do I directly reference a Bitmap resource within a DLL?

Hi everyone

I'm trying to create a taskpad for an MMC application that I'm developing, and I'm trying to reference a Bitmap image directly inside a DLL.

The Microsoft help for the API that I'm using (http://msdn.microsoft.com/en-us/site/aa815106) suggests that

The string should have the following form:

res://filepath/imgpath

where filepath is the full path to the snap-in's DLL that stores the image file as a resource, and imgpath is the resource path of the image file with the snap-in DLL.

I can't figure out what the imgpath should be, I've tried referencing the filename as it is on disk, in the folder that it lives in but that doesn't work. I've tried using a resource editor to look directly inside the DLL and use what that displays, but again I can't get it working. I have everything working by loading directly from an image on disk so I'm sure everything else it ok, I just need to reference an image that is locked inside a DLL instead of one on disk.

Can anyone point me in the right direction please ?

Thanks
Ant
With the caveat that you need to have loaded the DLL with the calling process you can use
GetModuleHandle to get a handle to the dll and LoadImage to load the bitmap resource. You can find the specifics of both functions easily on MSDN.


Thanks for the reply, however LoadImage and Load Resource won't allow to do what I need to do. To use the MMC_TASK structure I need to pass a URL to the image directly, I can't use a CBitmap object or something similar.

I've actually figured this out now, the format needed is

res://filepath/imgpath

where filepath is the path to the DLL, and imagepath (for bitmaps) is #2/#x where x is the resource identifier for the bitmap resource.

I found this information here:

http://msdn.microsoft.com/en-us/library/aa969614(v=vs.85).aspx
Topic archived. No new replies allowed.