=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 05-16-93 (18:13) Number: 17 From: JOE NEGRON Refer#: NONE To: SEAN SULLIVAN Recvd: NO Subj: Adding Data to end of .E Conf: (35) Quick Basi --------------------------------------------------------------------------- SS> I need to know the method of adding and reading data stored at the > end of a .EXE file. This is going to be used for configuration and > registration purposes. Thanks in advance. Here is an example program I wrote for someone some time ago: =========================== Begin EXEHDR.BAS =========================== DEFINT A-Z DECLARE FUNCTION GetEXESize& (FileSpec$, Handle%) TYPE UserData 'Define our record structure Name AS STRING * 20 Executed AS INTEGER END TYPE DIM User AS UserData 'Allocate space for our record FileSpec$ = "exehdr.exe" 'Name of program EXESize& = GetEXESize&(FileSpec$, Handle%)'Get executable file size FileSize& = LOF(Handle%) 'Get true file size DataLoc& = EXESize& + 1 'Set pointer to data IF FileSize& = EXESize& THEN 'No user info yet PRINT "No user info yet..." INPUT "Please enter your name: ", User.Name ELSE GET Handle%, DataLoc&, User 'Read user info END IF User.Executed = User.Executed + 1 'EXE has been run another time PRINT "User: "; User.Name PRINT "Times executed:"; User.Executed PUT Handle%, DataLoc&, User 'Write new data CLOSE Handle% SYSTEM '***************************************************************************** '* FUNCTION GetEXESize& '* '* PURPOSE '* This function returns the size of an EXE in a long variable. '* Note that this routine does not close the file '* '* PARAMETER(S) '* FileSpec$ - EXE from which to get file size. '* '* Handle% - File handle used to open FileSpec$. '***************************************************************************** FUNCTION GetEXESize& (FileSpec$, Handle%) STATIC Handle% = FREEFILE 'Get a free file handle OPEN FileSpec$ FOR BINARY AS Handle% Hdr$ = SPACE$(6) 'Read first six bytes GET Handle%, 1, Hdr$ ' of EXE header 'Calculate the number of partial pages used in the EXE, if any. 'Bytes three and four hold this info. PartialPages& = ASC(MID$(Hdr$, 4)) * 256& + ASC(MID$(Hdr$, 3)) 'Calculate the # of whole pages. WholePages& = ASC(MID$(Hdr$, 6)) * 256& + ASC(MID$(Hdr$, 5)) IF PartialPages& THEN 'Are there any fractional pages? WholePages& = WholePages& - 1 'Subtract one from page count END IF 'Return the EXE size (the number of whole pages plus any partial page) GetEXESize& = WholePages& * 512& + PartialPages& END FUNCTION ============================ End EXEHDR.BAS ============================ =========================== Begin EXEHDR.MAK =========================== EXEHDR.EXE: exehdr.obj link /EX/NOE exehdr smallerr,,NUL,bcl71anr qbx.lib; EXEHDR.OBJ: exehdr.bas bc exehdr /O/G2/FPa; ============================ End EXEHDR.MAK ============================ --Joe in Bay Ridge, Brooklyn, NY, Sun,05-16-1993-- --- Maximus 2.01wb * Origin: * BlueDog BBS * (212) 594-4425 * NYC FileBone Hub (1:278/709) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 575 950 203/23 209/209 SEEN-BY: 261/1023 280/1 390/1 396/1 15 397/2 2230/100 2440/5 3603/20