www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [Newbie!!] can I embed a file in my ecutable?

reply "Digital Mars" <ld galador.net> writes:
Let's say I want to use to write a simple installer.
Can I embed a Zip file inside my executable?
If so, how?

Thanks! :)
May 14 2011
parent reply Jimmy Cao <jcao219 gmail.com> writes:
--001485f7ce7a83252204a34a4354
Content-Type: text/plain; charset=ISO-8859-1

Write a .rc file, and compile it with rcc (from Digital Mars).
That gives you a .res file.

So, for example, let's say you want to embed yolk.zip into an exe.

First, write yolk.rc with one line:
300 RCDATA "yolk.zip"

Then run this:
rcc yolk.rc

Then do this:
dmd egg.d yolk.res

Then the egg.exe should have yolk.zip embedded.

--001485f7ce7a83252204a34a4354
Content-Type: text/html; charset=ISO-8859-1

<div>Write a .rc file, and compile it with rcc (from Digital
Mars).</div><div>That gives you a .res file.</div><div><br></div><div>So, for
example, let&#39;s say you want to embed yolk.zip into an
exe.</div><div><br></div>

<div>First, write yolk.rc with one line:</div><div>300 RCDATA
&quot;yolk.zip&quot;</div><div><br></div><div>Then run this:</div><div>rcc
yolk.rc</div><div><br></div><div>Then do this:</div><div>dmd egg.d
yolk.res</div><div>

<br></div><div>Then the egg.exe should have yolk.zip embedded.</div>

--001485f7ce7a83252204a34a4354--
May 14 2011
next sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
 Let's say I want to use to write a simple installer.
 Can I embed a Zip file inside my executable?
 If so, how?

 Thanks! :)

An alternative to using resources is the following: auto zip_file = cast(immutable ubyte[])import("zip_file.zip"); You need to specify the -Jpath switch in order for DMD to eat it. Also see http://www.dsource.org/projects/tutorials/wiki/ImportFile . Timon (Also consider digitalmars.D.learn for future questions.)
May 15 2011
parent "Digital Mars" <ld-REMOVE galador.net> writes:
Awesome!! Impressed by D!
While I'm a .NET enthusiast, the crappy Install project from VS are 
motivating me to give D a Go! (Pun inside! :)

I will also add D.learn to the newsgroup I'm watching then! :)


"Timon Gehr"  wrote in message news:iqocf4$1ihv$1 digitalmars.com...

 Let's say I want to use to write a simple installer.
 Can I embed a Zip file inside my executable?
 If so, how?

 Thanks! :)

An alternative to using resources is the following: auto zip_file = cast(immutable ubyte[])import("zip_file.zip"); You need to specify the -Jpath switch in order for DMD to eat it. Also see http://www.dsource.org/projects/tutorials/wiki/ImportFile . Timon (Also consider digitalmars.D.learn for future questions.)
May 15 2011
prev sibling parent "Digital Mars" <ld-REMOVE galador.net> writes:
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks, good to know!

"Jimmy Cao" <jcao219 gmail.com> wrote in message =
news:mailman.179.1305439270.14074.digitalmars-d puremagic.com...
Write a .rc file, and compile it with rcc (from Digital Mars).
That gives you a .res file.

So, for example, let's say you want to embed yolk.zip into an exe.

First, write yolk.rc with one line:
300 RCDATA "yolk.zip"

Then run this:
rcc yolk.rc

Then do this:
dmd egg.d yolk.res

Then the egg.exe should have yolk.zip embedded.
May 15 2011