The easiest way I know to include external files into an EXE is to add a myapp.rc file to your project.
A sample of one of my .rc files is listed below.
 
/////////////////////////////////////////////////////////////////////////////
 
touchStone_dot_mdb      files  DISCARDABLE     "touchStone.mdb"
toolbar_names           files  DISCARDABLE     "..\images\toolbar.txt"
sourcesafe_tick         icon   DISCARDABLE     "..\images\sourcesafe_tick.ico"
sourcesafe_cross        icon   DISCARDABLE     "..\images\sourcesafe_cross.ico"
toolbar20_mono          bitmap DISCARDABLE     "..\images\SHDOCVW_DLL_Bitmap_272.bmp"
toolbar20_color         bitmap DISCARDABLE     "..\images\SHDOCVW_DLL_Bitmap_273.bmp"
toolbar16_mono          bitmap DISCARDABLE     "..\images\SHDOCVW_DLL_Bitmap_274.bmp"
toolbar16_color         bitmap DISCARDABLE     "..\images\SHDOCVW_DLL_Bitmap_275.bmp"
toolbar20_monox         bitmap DISCARDABLE     "..\images\SHDOCVW_DLL_Bitmap_276.bmp"
toolbar20_colorx        bitmap DISCARDABLE     "..\images\SHDOCVW_DLL_Bitmap_277.bmp"
 
/////////////////////////////////////////////////////////////////////////////
The column on the left is the resource name and their are various loadfromresource methods that can be used.
My Touchstone application requires a Touchstone.mdb file so I will use the function below to make sure it exisits and
if not create it with the resource. No compression I'm afraid, but then I'm lazy.
 
procedure checkFileExists(const fname:string;resourcename:string);
var
  stmRes :TResourcestream;
  stmFile :TFileStream;
  dotPos :integer;
begin
  try
    if not fileexists(fname) then
    begin
      if resourcename='' then
        resourcename := fname;
      dotPos := pos('.',resourcename);
      if dotPos >0 then
        resourcename := copy(resourcename,1,dotPos-1)+'_dot_'+copy(resourcename,dotPos+1,100);
      stmRes := Tresourcestream.create(Hinstance,resourcename,'FILES');
      stmFile := Tfilestream.Create(fname,fmCreate);
      stmFile.CopyFrom(stmRes,0);
      stmRes.Free;
      stmFile.free;
      showmessage(fname + ' has been created.');
    end
  except
    on E:exception do
    begin
      if assigned(stmRes) then stmRes.free;
      if assigned(stmFile) then stmFile.free;
      e.message := e.message + ^J^M + ' in checkfileexists(' + fname + ')';
      raise;
    end;
  end; {of try}
end; {of checkFileExists}
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Steven Wild
Sent: Friday, February 04, 2000 1:31 PM
To: Multiple recipients of list delphi
Subject: [DUG]: resources

How do we go about storing a several files (LZh's) in one exe.  The Exe would run, decompress the files to a temp directory and then install them in various places in a users system (based on registry settings).  This would upgrade an existing application, with the user only needing to run one app. 
 
We can do the decompression (thanks to SPIS's wonderful components) but how do we wrap the LZH file (or any other file) into a delphi app (presumably as a resource??).
 
If it is a resource, do we need a resource editor to create the resource file??
 
Steven
 
Wild Software Ltd
*Chreos Business Systems
CHCH, NZ

Reply via email to