Hello, im programming a gui and like to use some sound and bitmaps for this. i like to use the resources inside the exefile so the user cant edit the files(like setting a new sound or changing my logo) im not shure if this is possible ,but i like to use a dll for this. can i put resources inside a dll and then my programm load the wave and bitmaps from the dll ? if not ,can i put the files inside the exe file ? thanks and cu
Posted on 2001-02-08 04:29:00 by WH¥
you sure can, look at some of the files that come with masm32, such as \MASM32\EXAMPLE2\BMBUTTON, and you will see the icons and bitmaps, also you will see a file called rsrc.rc. This file is called a resource script file. All that means is that, you run that file through a program which adds all those icons and bitmaps into a another file, this is the rsrc.res file. New you run rsrc.res through another program which converts it into a file which is usable by masm. Thi is called rsrc.obj. Now when you compile your exe, you will notice the link process is a little different...\MASM32\BIN\Link.exe /SUBSYSTEM:WINDOWS bmbutton.obj rsrc.obj <- note this last bit, this tells link to include all you bitmaps which are in that file in your final exe (or dll, the process is the same for a dll) Now to use these 'resources',all yourve gotta do is get the handle to the binary file in memory, ie, if all the resources are in you main exe

invoke GetModuleHandle ,NULL
mov hInst,eax
will do nicly. Now say to load a bitmap,

invoke LoadBitmap ,hInst,10 ;The 10, is the unique id of the bitmap in rsrc file
mov hBmp,eax
and now unless an error occoured, hBmp is a valid handle to a bitmap
Posted on 2001-02-09 06:22:00 by George
Hello, thanks for the long answer :) im trying to use undertsand and use it. Thanks !
Posted on 2001-02-09 20:57:00 by WH¥
Hi friend: Try this: load your bitmap in a text processor like word as only text format and copy it. Then in your .data section put a label myBitmap DB 'long of bitmap' dup (0) and paste the data of your bitmap. Now your data has the binary of your bitmap file. When you use this dll you must to save first the data in the hard disk with the name of file myBitmap.bmp and use it as ever. best regards
Posted on 2001-02-09 21:52:00 by JR
Hi JR, This is an excellent idea to partially hide the bitmap. It is very primitive process just by using LoadImage from file in the directory or by LoadBitmap if is from resource, which reside in the EXE file. According to your receipt you have the BMP image in the .data - then you write it to the drive and loaded in run time. Couldn't be we read this image straight from .data and use say the Label as an Idxx or BitBlt. As the image is in the .data, it is loaded in to memory at run time anyway. Anybody have any idea or remark or it is just my stupid thinking? Thanks for any comment. forge :confused:
Posted on 2001-02-17 21:19:00 by forge