Marco Alvarado wrote 13 lines
Hello! I want to read data from my executable files. This data is
appended to the file, and would like to read it directly instead of
loading another copy of the file. I'm think on using a function like
this:
function PeekExeByte(Byte2Get: Integer): byte;
Begin
If Byte2Get < 1 then Exit;
Result := byte(pointer(Hinstance+Byte2Get-1)^);
End;
Should work on Windows, but I'd like to know if you see any problems I
could have with other platforms?
If you really talk about just appending data at the end of the executable file, I wouldn't expect this to work on any platform except the most primitive ones (like .COM files at DOS times), because most operating systems define structure of the executable file and only load into memory the parts they really need. There are other ways for doing this like directly embedding your data as constants in your program (using something like data2inc), adding data as resources, using standalone data file instead of misusing the EXE file, etc.
Tomas