Article ID: 84062 - View products that this article applies to.
This article was previously published under Q84062
Appending data to the end of an executable file may be useful when you need to include data with your program but do not want to have extra data files. The method shown in this article involves reading the executable file header to determine the program image (the actual size of the executable part of the file) at run time to determine the position of the data at the end of the executable file. Once the position of the data has been determined, the executable file can OPEN itself for BINARY access and read the data.
Although this method has been tested in limited use with Microsoft Basic products, it is not officially supported or guaranteed by Microsoft, and has not been extensively tested.
This information applies to Microsoft QuickBasic version 4.5 for MS-DOS and to Microsoft Basic PDS versions 7.0 and 7.1 for MS-DOS.
The first step in this process is to get the executable header information. This is documented in the "Microsoft MS-DOS Programmers Reference" (published by Microsoft Press). The following is the format of an executable header as defined by a QuickBasic program:
The two fields exExtraBytes and exPages can be used to compute the size of the image area of the executable, and thus the beginning of the data area.
The following is a small program that will create a data file containing a graphics image created with the PRINT and LINE statements in Basic:
The next example should be compiled and have the data file from the previous program appended on the end of the executable. Type in the following program, and save it with the name TEST.BAS:
After compiling this program into TEST.EXE, use the MS-DOS TYPE command to append the data file to the end of the executable as follows:
type datafile >> test.exeRun the program and you will see the image that was created in first program displayed in the second program.
For more information about the format used by the graphics PUT and GET statements to store images into an array, query on the following words in the Microsoft Knowledge Base:
get and put and array and graphics and pixels and image
Article ID: 84062 - Last Review: August 16, 2005 - Revision: 2.1
Contact us for more help
Connect with Answer Desk for expert help.