FoxPro allows users to embed files into an APP or EXE file using the project manager. That means an icon or JPG can be embedded inside so it can’t be used externally except by the application. However, there is a bug in some file functions that attempt to read the embedded file in certain scenarios. A simple workaround is to make a temporary copy of the file on disk and use that copy. Another workaround is to keep the file on disk and not to embed the file at all.
The code below builds a project called Test2, embeds an icon file, builds test2.exe, and runs it. The code opens and displays the sizes of the embedded icon file and the copy on disk. If you run it, the Embedded Size will show some random number, whereas one would expect the two to be the same.
SET SAFETY OFF
CLOSE DATABASES all
#define ICONFILE HOME(0)+"graphics\icons\computer\disk01.ico"
#define PHYSICON "temp.ico"
COPY FILE ICONFILE TO PHYSICON && make temporary copy that is physically on disk
TEXT to xmyvar && create code for test2.exe
hnd=FOPEN(ICONFILE,10) && open unbuffered, readonly
nSize=FSEEK(hnd,0,2) && Seek to EOF returns file size
hnd=FOPEN(PHYSICON,10) && open unbuffered, readonly
MESSAGEBOX("Embedded Size = "+TRANSFORM(nSize)+" Size on Disk="+TRANSFORM(nSize2),0,_vfp.FullName)
BUILD PROJECT test2 FROM test2
MODIFY PROJECT test2 nowait
_vfp.ActiveProject.Files.Add(ICONFILE) && embed the icon. Comment out this line and it works
BUILD EXE test2 FROM test2