- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here are some replies to a recent similarquery on COMP.OS.MS-WINDOWS.PROGRAMMER.WIN32 NEWSGROUP about how to add bitmap files as resources to an executable. Although the answers are C++-oriented, the windows API routines are callable from CVF/IVF I believe.There are some useful links in the first reply.Hope they help.
Code:
REPLY#1 > > Use the following API's to combine several resource files into > a single executable object program: > > // Include the files... > > CreateFile() using GENERIC_READ, > 0, > NULL, > OPEN_EXISTING, > FILE_ATTRIBUTE_NORMAL, > NULL); > > GetFileSize(hFile, NULL); > ReadFile() > CloseHandle() > > > // Update the resource data... > > BeginUpdateResource() > UpdateResource() > EndUpdateResource() > > > // Extract the data... > > LoadLibraryEx() > FindResource() > LoadResource() > LockResource() > FreeLibrary() > > > // Save the data into a file... > > SizeofResource() > CreateFile() using GENERIC_WRITE, > 0, > NULL, > CREATE_ALWAYS, > FILE_ATTRIBUTE_NORMAL, > NULL); > WriteFile() > CloseHandle() > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/createfile.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getfilesize.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/readfile.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/beginupdateresource.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/updateresource.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/endupdateresource.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibraryex.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/findresource.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/loadresource.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/lockresource.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/freelibrary.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/sizeofresource.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/writefile.asp > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/closehandle.asp > > Hope these information helps, > > Kellie. > REPLY#2 > "Software Design"wrote: > >Is there a way to include files with my executable program, > >that I can extract duri ng the run-time process ? > > Create a ".rc" file with contents like this: > > 1 RCDATA "data.zip" > 2 RCDATA "picture.bmp" > > Add the .rc file to your project. > > Then in the .cpp code of your executable, use code like this: > HRSRC hrsrc=FindResource(hInstance,MAKEINTRESOURCE(2),RT_RCDATA); > DWORD size=SizeofResource(hInstance,hrsrc); > HGLOBAL hglob=LoadResource(hInstance,hrsrc); > void *buf=LockResource(hglob); > // > HANDLE hf = CreateFile("pic.bmp",...); > WriteFile(hf,buf,size,...); > CloseHandle(hf); >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Im getting closesolving my problem.
In my code I load a bitmap file via loadimage_w to display it in an QuickWin Window. But the
disadvantage is, that I have to deliver the .bmp file with my program. So I included it in the
Resource Editor and try to load it from there. Because QuickWin does only allow to load
images from file, I try to save the Resource Bitmap in a file:
Code:
hBmp=FindResource(GetModuleHandle(NULL),245,RT_BITMAP) hSize=SizeofResource(NULL,hBmp) hRes=LoadResource(NULL,hBmp) hLock=LockResource(hRes) hFile=CreateFile(tempstring,GENERIC_WRITE,null,null,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,null) l=WriteFile(hFile,hLock,hSize,loc(byteswritten),null) l=SetEndOfFile(hFile) l=CloseHandle(hFile)
That does nearly the trick. A new file was created.
The code of my two bitmaps are identical, but the new file misses the bmp header I think.
Original file begins with:
BM v ( A 8
New file begins with:
( A 8
Or would be another way to copy the resource bitmap into memory and paste it the putimage on the QuickQin dialog?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or, better still, drop the QuickWin altogether :-). See also this xeffort sample.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Getting rid of QuickWin *sigh* I dont exaggerate when I say that sometimes I dreamt of it at night :-)
Our company will move to VS2005 at the beginning of the next year, so I only have to use QuickWin for another 6 months.
Thanks, your link/example works fine. They always do!
Markus

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page