Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to extract a file from a compiled exe at runtime?

Status
Not open for further replies.

ganj

IS-IT--Management
Nov 3, 2001
19
AT
I want to include a zip file into my project. Is there a way to copy (extract) a file embedded in the compiled exe to a folder? I want to avoid distribuiting the zip file as a separate file, rahter it should be embedded in the application.

TIA, JoGa
 
If you add it to your project and make sure it is INCLUDEd, it will be compiled into your EXE file. The app can then access the file as if it were in the directory.

Ian
 
HI ganj,
It is not that simple as to include it in the project and then distribute. The reason is how to use the included file. Commands such as COPY FILE to copy the included file to another file anme or directly running unzip command dont work, since the files needs to be present in the harddisk as an independent file. VFP behaves differently from FP 2.6 version where in such files can be included in the application and copied using those command.

The work around could be by including the zip or self extracting exe file in a general field of a table and then this can be copied first into the harddisk default directory and then unziped. This I havent tried so far, but should work.

Hope this helps you :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Ganj,

I've also had occasion to include an external file in the project. I've wanted to ensure that a specific font was available on the users machine, so on my end I renamed the file to something "safe" like 'myfont.ttf' became 'myfont.ftt'. I then included the 'ftt' file in the project. I wrote a routine to see if the font was already installed. If it wasn't I'd COPY FILE MYFONT.FTT TO MYFONT.TTF and then install the font. I've also sent executables by changing the extension to 'XEX'.

Steve
 
I've taken the approach of, in my release procedure (that automatically builds the .APP file, etc) I create a table with a memo field, FileToStr() each file I want to distribute and stick each in a record (the record also has a field for the file name). Then I include this .DBF in the .APP as an included file.

On the user's machine (during the install of the .APP file, which is an addon for a VFP .EXE file) I just StrToFile() out of the memo field onto the disk to the right filename.
 
Another way to check for and extract an .EXE is the following:
lcFilename = "META.EXE"
lcPath = "C:\"
IF ADIR(laTemp, lcPath+lcFilename) <> 1 && Not There
IF FILE(lcFilename) && FILE() works &quot;inside&quot; VFP .EXEs
** cute kludge complements Vlad Grynchyshyn on the UT **
CREATE CURSOR ttt (ttt M)
APPEND BLANK
APPEND MEMO ttt.ttt FROM &lcFilename
lcSvSafety = SET(&quot;SAFETY&quot;)
SET SAFETY OFF
COPY MEMO ttt.ttt to (lcPath+lcFilename)
IF lcSvSafety <> &quot;OFF&quot;
SET SAFETY OFF
ENDIF
USE IN ttt
ENDIF
ENDIF

Note: You could also always copy it out or check the date on the existing file and check to see if the code file version is new, etc.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top