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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract embedded file

Status
Not open for further replies.

chrisjohnson

Programmer
Mar 15, 2001
24
0
0
US
Hi, I want to create an EXE to use as a makeshift installation program. I include the Apps in the project and create the exe. What I want to do is have the program copy the imbedded file out to the hard drive. I've done something similiar before when the file is a table - just use the dbf and copy. But for a non-table the "copy file to" command won't work, it only looks on disk not in the exe. Does anyone have any ideas? Low level commands maybe. I know I could create a regular install with something like installshield wizard, but I have coded this to do certain processes automatically.

Thanks,
Chris Johnson
 
This is one technique that I have used. I remember reading about another one, but I can't seem to find it right now. In some applications I embed a self extracting ZIP .EXE with some meta data in it that is tied to the application version. This is how I get it out. Note: If the version changes, I explicitly remove the external file, and the checking is so I don't extract it each time the code is run.
Code:
lcExternalFile = "Meta.EXE"
...

 IF !GOTFILE(lcExternalFile) ;
     AND FILE(lcExternalFile) && FILE() works "in" .EXE
  ** cute kludge complements Vlad Grynchyshyn on the UT **
  CREATE CURSOR ttt (ttt M)
  APPEND BLANK
  APPEND MEMO ttt.ttt FROM (lcExternalFile)
  lcSvSafety = SET("SAFETY")
  SET SAFETY OFF
  COPY MEMO ttt.ttt to (lcExternalFile)
  IF lcSvSafety <> "OFF"
    SET SAFETY OFF
  ENDIF
  USE IN ttt
ENDIF

*Where GOTFILE.PRG only works with REAL files and is:
FUNCTION gotfile
LPARAMETERS zcfilename
IF TYPE("zcfilename") <> "C"
	RETURN .F.
ENDIF
DIMENSION laJunk[1] && so it's local 
RETURN (ADIR(laJunk, zcfilename, "ARS") > 0)

* Note: Conscious decision to not include Hidden files was made so it matched results
*       of previous GOTFILE() AND FILE().
Rick
 
Hi,

Let me know if I have misunderstood...

You have an application which needs to place an executable on the target machine at or after install?

I do this by creating a free table which is included in the exec. There are two fields, one to identify the file and one as a binary memo.

I get the .exe file into the memo by adding the record first - then using filetostr to get the data into it.

When the app is run, I check for the exec file and if it is absent, use strtofile to extract the contents of the binary memo to disk.

Does this help?

Regards

Griff
Keep [Smile]ing
 
Thank you both for the replies. I tried rgbean's suggestion and it worked great. GriffMG, I'm sure your's would as well. Both are based on the same principle - get an EXE, or in my case, an APP into a memo field and then at some point write it to disk. I knew there are some commands that will look in the exe for a file if it can't find it anywhere else, like USE or FOPEN, but "copy file to" isn't one of them. Again, thanks for the workaround, I appreciate the help.

Chris Johnson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top