News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Reading resource sections

Started by sharpe, June 22, 2011, 11:55:43 AM

Previous topic - Next topic

sharpe

Hi all,

I am writing a small app that stores an image and an MP3 file in the app itself as resources, which is used by the app after it is running.
I have tried to to read the resources using the FindResource() API but am having all sorts of trouble (LastError = 718h).
Does anyone have an example or perhaps some tips regarding this?

I look forward to hearing from you.

regards,
sharpe.

dedndave

in the resource file, you assign a unique ID number, then refer to that ID
here is a simple example with a sound file...
http://www.masm32.com/board/index.php?action=dlattach;topic=15882.0;id=8764

in the ASM file, notice the EQUate
IDS_PMF EQU     1000
;
;
;
        INVOKE  PlaySound,IDS_PMF,hInstance,SND_RESOURCE


and, in the resource file...
#define  IDS_PMF  1000

IDS_PMF  WAVE DISCARDABLE "PMF.wav"

the resource text for a bitmap is very similar, except you use "BITMAP" instead of "WAVE"

sharpe

Sweet, you just gave me another idea, nice.
But if I didn't want to play them, just access the raw data of the image and mp3, would find resource work?

INVOKE PlaySound... nice..

Thanks.

baltoro

Here is an old MSDN article (1994) by Matt Pietrek: Peering Inside the PE: A Tour of the Win32 Portable Executable File Format. Scroll down about 3/4 of the way, and, there is a section that describes the PE File Resources. It's good stuff,...but, some serious overkill.

Baltoro

sharpe

baltoro,

I know that article, awesome. I'll have a butchers.
Thanks!

Vortex

Hi sharpe,

Why not to embed the image and the sound file into the executable? The trick is to convert binary files to MS COFF object modules to be linked with your project module.

baltoro

Baltoro

Vortex

Hi sharpe,

Here is a resource example for you.

sharpe

Hi Vortex, that's smashing, thanks very much!