Just starting out? Need help? Post your questions and find answers here.
GeoTrail
Addict
Posts: 2794 Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:
Post
by GeoTrail » Sat May 22, 2004 9:07 pm
I'm trying to make a simple update program for a project.
So I need to inlclude an updated exe file in the update program and then be able to copy the file to it's destination.
Code: Select all
CopyFile(?file,"C:\filename.exe")
DataSection
file:
IncludeBinary "filename.exe"
fileend:
EndDataSection
That is what I got so far.
Could someone please help me with this?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
GPI
PureBasic Expert
Posts: 1394 Joined: Fri Apr 25, 2003 6:41 pm
Post
by GPI » Sat May 22, 2004 9:28 pm
Try CreateFile(), WriteData(),CloseFile()...
GeoTrail
Addict
Posts: 2794 Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:
Post
by GeoTrail » Sat May 22, 2004 9:50 pm
Could you please give me an example how those functions could be used with my code?
I tried this but it only makes an empty file:
Code: Select all
Result = CreateFile(0, "filename.exe")
WriteData(*MemoryBuffer, ?File)
CloseFile(0)
DataSection
File:
IncludeBinary "filename.exe"
fileend:
EndDataSection
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
GeoTrail
Addict
Posts: 2794 Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:
Post
by GeoTrail » Sat May 22, 2004 10:29 pm
Anyone? Please?
Code: Select all
CreateFile(0, "filename.exe")
WriteData(?File,Length)
CloseFile(0)
DataSection
File:
IncludeBinary "filename.exe"
Fileend:
EndDataSection
The include thing works, I see that the compiled exe gets alittle bigger than the included file. But I can't seem to write the file to disk.
Anyone?
PLEASE??
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Sat May 22, 2004 10:33 pm
not sure, but you haven't defined length.
GeoTrail
Addict
Posts: 2794 Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:
Post
by GeoTrail » Sat May 22, 2004 10:37 pm
I know, I don't know how to do that.
I've tried Lof() but it only returns 0 as the file has no content after CreateFile()
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Sat May 22, 2004 10:40 pm
Code: Select all
a=OpenFile(#PB_ANY, ?File)
Length=Lof()
CloseFile(a)
CreateFile(0, "filename.exe")
WriteData(?File,Length)
CloseFile(0)
DataSection
File:
IncludeBinary "filename.exe"
Fileend:
EndDataSection
I haven't checked if it works, but it's supposed to
GPI
PureBasic Expert
Posts: 1394 Joined: Fri Apr 25, 2003 6:41 pm
Post
by GPI » Sat May 22, 2004 10:41 pm
Try:
Code: Select all
CreateFile(0, "filename.exe")
WriteData(?File,?fileend-?file)
CloseFile(0)
DataSection
File:
IncludeBinary "filename.exe"
Fileend:
EndDataSection
GeoTrail
Addict
Posts: 2794 Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:
Post
by GeoTrail » Sat May 22, 2004 10:47 pm
Polo wrote: Code: Select all
a=OpenFile(#PB_ANY, ?File)
Length=Lof()
CloseFile(a)
CreateFile(0, "filename.exe")
WriteData(?File,Length)
CloseFile(0)
DataSection
File:
IncludeBinary "filename.exe"
Fileend:
EndDataSection
I haven't checked if it works, but it's supposed to
I get this errormessage when trying to compile:
Bad parameter type: a string is extected.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
GeoTrail
Addict
Posts: 2794 Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:
Post
by GeoTrail » Sat May 22, 2004 10:51 pm
GPI wrote: Try:
Code: Select all
CreateFile(0, "filename.exe")
WriteData(?File,?fileend-?file)
CloseFile(0)
DataSection
File:
IncludeBinary "filename.exe"
Fileend:
EndDataSection
That worked great
Thanks.
Only thing is, it generates a Windows error while running the program.
The filename.exe file works great.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
eriksradio
User
Posts: 30 Joined: Tue Sep 09, 2003 11:44 pm
Location: Queensland, Australia
Post
by eriksradio » Sat May 22, 2004 11:33 pm
This works for me if it is any help
If CreateFile(1, "filename.exe")
UseFile(1)
L1 = ?ExitProc - ?Inc
WriteData(?Inc, L1)
CloseFile(1)
Goto BeginProgram1
Inc :
IncludeBinary "filename.exe"
exitProc:
EndIf
BeginProgram1:
GeoTrail
Addict
Posts: 2794 Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:
Post
by GeoTrail » Sun May 23, 2004 12:08 am
Thanks eriksradio.
That worked great. No error
Any idea why
Code: Select all
CreateFile(0, "filename.exe")
WriteData(?File,?fileend-?file)
CloseFile(0)
DataSection
File:
IncludeBinary "filename.exe"
Fileend:
EndDataSection
causes an error? I've tried it on both Win2000 and WinXP, both reports an error.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
eriksradio
User
Posts: 30 Joined: Tue Sep 09, 2003 11:44 pm
Location: Queensland, Australia
Post
by eriksradio » Sun May 23, 2004 3:09 am
Sorry Geo, I don't really know.
I got this example from the PURE AREA site.
I downloaded the complete Code Archive
There is a wealth of info and examples there, a must have
for newbies like me.
I program mostly in VB.
When I can't do it in VB, I can usually do it and more in PB
Have fun
filperj
User
Posts: 77 Joined: Tue Sep 16, 2003 8:53 pm
Location: Nevers(France)
Post
by filperj » Sun May 23, 2004 5:09 am
No error for me, with xp home and PB 3.90. :roll:
Wich PB version do you use?
GeoTrail
Addict
Posts: 2794 Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:
Post
by GeoTrail » Sun May 23, 2004 11:50 am
I use v3.91 beta and jaPBe for 3.91b
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!