Page 1 of 1

Adding files into the exe and extracting them

Posted: Mon Aug 11, 2008 1:56 am
by Chirantha
How do I add some zip files, dll's, images to the exe file and extract them when the program starts?

Posted: Mon Aug 11, 2008 4:03 am
by netmaestro

Code: Select all

; Include the file(s) in exe:
DataSection
  beginzip: IncludeBinary "somefile.zip" endzip:
EndDataSection

; Write them to disk at runtime:
If CreateFile(0, "somefile.zip")
  If WriteData(0, ?beginzip, ?endzip-?beginzip)
    ; success
  Else
    ; error message
  EndIf
  CloseFile(0)
Else
  ; error message
EndIf

Posted: Mon Aug 11, 2008 5:16 am
by Rook Zimbabwe
Netmaestro... that is fascinating... is there a way to do this if the zip has a password?

Posted: Mon Aug 11, 2008 5:21 am
by Poshu
Hummm... This is pretty basic stuff using datasection. It has nothing to do with zip, so you can add any type of binarie, including password protected zip...

Posted: Mon Aug 11, 2008 6:16 am
by Fangbeast
The trouble with including loads of things inside an exe (as I understand it) is that the entire thing has to be loaded into memory first, which includes everything inside the exe and that could impact on any machine not having enough RAM.

Might be more efficient and useful to include a resource bin that doesn't get loaded into memory. One such useful thing that comes to mind is DoubleDutch's DBIN.

You might want to check out

http://www.purebasic.fr/english/viewtop ... n&start=45

Posted: Mon Aug 11, 2008 3:14 pm
by Rook Zimbabwe
I click on the link in the purearea.net website and it simply displays the info about PBOSL No download!

Ahhh I see... you have to download the entire PBOSL... No one exactly mentioned that! 8)

Posted: Mon Aug 11, 2008 3:24 pm
by Fangbeast

Posted: Mon Aug 11, 2008 11:56 pm
by ar-s
Rook Zimbabwe wrote:Netmaestro... that is fascinating... is there a way to do this if the zip has a password?
Same way with using gnozal PureZip Lib to unzip ! :P

Posted: Tue Aug 12, 2008 12:06 am
by Kaeru Gaman
Fangbeast wrote:Might be more efficient and useful to include a resource bin that doesn't get loaded into memory. One such useful thing that comes to mind is DoubleDutch's DBIN.
wasn't there an integrated ressources manager since 4.0 or so?
I'm not sure how it works, didn't use it yet...

Posted: Tue Aug 12, 2008 11:59 am
by PB
> The trouble with including loads of things inside an exe (as I understand
> it) is that the entire thing has to be loaded into memory first, which
> includes everything inside the exe and that could impact on any machine
> not having enough RAM.

I've heard that too, but nothing beats a self-contained single executable. ;)