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:
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 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:
	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