SAMPLE: RESFILE.EXE Stores Any File Type in a Resource File
This article was previously published under Q194409 SUMMARY RESFILE.EXE is a sample project that shows how to store any
file type in a resource file and retrieve the file for use at run-time.
MORE INFORMATIONThe
following files are available for download from the Microsoft Download
Center: Resfile.exe (http://download.microsoft.com/download/vb60ent/samp10/1/win98/en-us/resfile.exe) Release Date:
Oct-19-1998For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base: 119591 (http://support.microsoft.com/kb/119591/EN-US/) How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.
Programmers often want to use files with their application, but do not want to install these files into the application directory for fear that the user might delete or modify them. Examples of this include an RTF or Word file for a "Readme" file, GIF and JPG files for images, or MIDI files for sound and data files. One of the ways to distribute these required files is to include them in a resource file. The resource file is compiled into the EXE. This makes the included files available to the program, but keeps the user from being able to modify them. A resource file can contain any type of data. It can load certain types of data directly, such as bitmaps, icons, and strings using LoadResPicture and LoadResString. Other types of data must be stored in the resource file as a "custom" resource. Custom resources must be retrieved from the resource file using the LoadResData function intrinsic to Visual Basic. Although the Visual Basic Help file says "The data that LoadResData loads from the resource file can be up to 64K," this is a limitation for the 16- bit versions of Visual Basic. The 32-bit versions of Visual Basic have no problem reading larger amounts of data. To use the custom resource, you can simply use the LoadResData function to retrieve the resource into a byte array, then save the byte array to a temporary file, use the file, and then delete the temporary file. The Resfile.exe sample has a reusable module for handling these resource file operations. This module has two functions to make the resource file tasks easier.
APPLIES TO
| Article Translations
|

Back to the top
