Board index » delphi » Q: Including files in the EXE file?

Q: Including files in the EXE file?

Hi,

Can anyone tell me how I can include a file (let's say a WAV-file) in my
Executable?

I guess you all know those programs of only one executable that do play sounds
or animations. That's where I wanna get....

C-ya!

        Arjan
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Arjan van de Logt
E-mail: avdl...@worldaccess.nl
http://www.worldaccess.nl/~avdlogt
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

Re:Q: Including files in the EXE file?


On Mon, 30 Dec 1996 10:08:42 GMT, avdl...@worldaccess.nl (Arjan)
wrote:

Quote
>Can anyone tell me how I can include a file (let's say a WAV-file) in my
>Executable?

Bind them up into a .RES file, using an RC script, then use
{$R Resfile.RES} to link them into your executable.

Re:Q: Including files in the EXE file?


 >Can anyone tell me how I can include a file (let's say a WAV-file) in my

Quote
> >Executable?

> Bind them up into a .RES file, using an RC script, then use
> {$R Resfile.RES} to link them into your executable.

Code from an UNDU help file:  (November 1996)
=========================
Put Anything In Your Delphi EXE!
by William A. Portillo - hall...@wantree.com.au
I don't know if this is useful stuff but after a couple of weeks of playing
with the resources side of Delphi, I ended up writing a routine that will
"extract" other files out of a Delphi EXE. I found this useful for
distributing little picture or sound files with the application or as a
setup program with internal files. No doubt many of you will find other
uses for this technique.

First, I create an RC project with NOTEPAD.EXE and ARJ.EXE in it as follows
(we'll call it RESJUNK.RC):

NOTEPAD EXEFILE C:\WINDOWS\NOTEPAD.EXE
        ARJ EXEFILE C:\UTILS\ARJ.EXE

then I compile it with BRCC32 into a RES file. After this I include it in
my Delphi project by using the $R compiler directive like this:

{$R RESJUNK.RES}

and extract this files by using the TResourceStream class.

procedure ExtractRes(ResType, ResName, ResNewName : String);
        var
          Res : TResourceStream;
        begin
          Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
          Res.SavetoFile(ResNewName);
          Res.Free;
        end;

==========================

--
--------------------------
Eric Lawrence
Delta Programming Group
Delta...@juno.com

Other Threads