Adding files into the exe and extracting them

Just starting out? Need help? Post your questions and find answers here.
Chirantha
User
User
Posts: 54
Joined: Sat Jul 16, 2005 7:22 pm

Adding files into the exe and extracting them

Post by Chirantha »

How do I add some zip files, dll's, images to the exe file and extract them when the program starts?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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
BERESHEIT
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Netmaestro... that is fascinating... is there a way to do this if the zip has a password?
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Post 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...
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post 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
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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)
Last edited by Rook Zimbabwe on Mon Aug 11, 2008 3:27 pm, edited 1 time in total.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
ar-s
Enthusiast
Enthusiast
Posts: 344
Joined: Sat Oct 06, 2007 11:20 pm
Location: France

Post 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
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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...
oh... and have a nice day.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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. ;)
Post Reply