Hellos,
I was wondering if any of you have created an auto updator that either downloads via HTTP or FTP. And have some sort of progress indicator & can download multiple files. Are there any samples out there or such?
Auto Updator sample w/ progress bars?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
I wrote an includefile for the SmartUpdate tool, which is avaiable here:
http://freak.purearea.net/code/DownloadUrlToFile.zip
It's advantage over the one Karbon has pointed to is, that it can handle
any type of transfer protocol that IE can handle, without you having to care
about which one it is. It also downloads in the background and though allows
you to download multiple files at once.
You can simply attatch a callback procedure to each download to monitor
the progress. An example is included.
Timo
http://freak.purearea.net/code/DownloadUrlToFile.zip
It's advantage over the one Karbon has pointed to is, that it can handle
any type of transfer protocol that IE can handle, without you having to care
about which one it is. It also downloads in the background and though allows
you to download multiple files at once.
You can simply attatch a callback procedure to each download to monitor
the progress. An example is included.
Timo
quidquid Latine dictum sit altum videtur
Oops back again, didnt want to have a huge dependency (IE) to rely on for the updator. Even though it has lots more features. The reason why I bought PB was so I can code w/o having to worry about major bloat dependencies and code. Thanks though I'll have to go the Karbon way
btw: there's a bug in Karbon's code, it does not work on most web servers.. try the following url for example...
http://www.mirageuniverse.com/downloads ... Online.zip
btw: there's a bug in Karbon's code, it does not work on most web servers.. try the following url for example...
http://www.mirageuniverse.com/downloads ... Online.zip
I had a look at the dependencies of my code, and i don't think that this
really is a problem:
MS Documentation says:
Minimum OS: Windows NT4.0, Windows 95
Minimum IE: 3.0
AFAIK Windows95 allready includes IE 4.0, and the NT Service packs include also updates for IE.
So only if anybody runs NT4.0 without any Service pack, he will have troubles.
(but then he also has one hell of a security hole in his OS )
Timo
really is a problem:
MS Documentation says:
Minimum OS: Windows NT4.0, Windows 95
Minimum IE: 3.0
AFAIK Windows95 allready includes IE 4.0, and the NT Service packs include also updates for IE.
So only if anybody runs NT4.0 without any Service pack, he will have troubles.
(but then he also has one hell of a security hole in his OS )
Timo
quidquid Latine dictum sit altum videtur
You can do of course without IE or Wininet
But more work for coder....
here a sample...from 2002...old......but with free bugs
But more work for coder....
here a sample...from 2002...old......but with free bugs
Code: Select all
; HTTP file download
;
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
#bufferlengte=10240
Global buffer
buffer = AllocateMemory(#1,#bufferlengte , 0)
Global buf$
Global EOL$
EOL$ = Chr(13)+Chr(10)
Global filenaam$
filenaam$="PureBasic_Update_3.81_Beta_1.zip"
server$="www.purebasic.com"
url$="http://www.purebasic.com/"
;http://www.purebasic.com/PureBasic_Update_3.81_Beta_1.zip
;
Port = 80
Global size
Global oldsize
Global rate
Global ratetel
Global buf$
Global header
Global startReceive
Global hwnd
Global ConnectionID
Global filesize
Global timeout
Global aniwin
Global h
Global einde
h=LoadLibrary_("Shell32.dll")
;
Procedure incoming(result)
b.b=0
b$=""
rest=0
Select header
Case 0
sendmessage_(AniWin,#ACM_OPEN,h,160)
i=0
Repeat
If PeekB(buffer+i)=13 And PeekB(buffer+i+1)=10 And PeekB(buffer+i+2)=13 And PeekB(buffer+i+3)=10
b$=Space(i+4)
CopyMemory(buffer,@b$,i+4)
rest=i
i=result-1
EndIf
i+1
Until i=result
;
Repeat
;
If Left(b$,2)=EOL$
If startreceive=1
b$=Mid(b$,3,Len(b$)-3)
If CreateFile(1,filenaam$)
WriteData(buffer+rest+4, result-rest-4)
header=1
size=result-rest-4
SetGadgetText(4,"Received "+Str(size)+" of "+Str(filesize)+" bytes")
Else
header=2
EndIf
EndIf
Else
search=FindString(b$, EOL$ , 1)
If search>0
l$=Left(b$,search-1)
b$=Mid(b$,search+2,Len(b$))
pos=FindString(l$,"200 " , 1)
If pos
startreceive=1 ; ok
Else
pos=FindString(l$,"404 " , 1)
If pos
;error 404 not founf
Else
pos=FindString(l$,"Content-Length:" , 1)
If pos
pos=FindString(l$," " , 1)
filesize=Val(Mid(l$,pos+1,Len(l$)))
EndIf
EndIf
EndIf
Debug l$
Else
l$=""
EndIf
EndIf ;
Until search=0
Case 1
timeout=0
WriteData(buffer, result)
size+result
SetGadgetText(4,"Received "+Str(size)+" of "+Str(filesize)+" bytes")
stap=100*size/filesize
SetGadgetState(2, stap)
If filesize=size
Debug "File Received"
header=2
Debug Str(size)+" of "+Str(filesize)+" bytes"
killTimer_(hWnd,1) ; 20 milisecond timer
killTimer_(hWnd,2) ; 1 sec timer
killtimer_(hWnd,3) ; 500 msec timer
CloseFile(1)
CloseNetworkConnection(ConnectionID)
Debug "Connection Closed"
DestroyWindow_(AniWin)
einde=1
EndIf
EndSelect
EndProcedure
;
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select WindowID
Case hwnd
Select message
Case #WM_TIMER
result=1
Select wparam
Case 1 ; timer
If NetworkClientEvent(ConnectionID)
result=ReceiveNetworkData(ConnectionID, buffer, #bufferlengte)
incoming(result)
EndIf
Case 2 ; timeout
timeout+1
If timeout>10
CloseFile(1)
header=2
Debug "Timeout"
EndIf
Case 3
ratetel+500
If ratetel>0
rate=size/ratetel
EndIf
SetGadgetText(3,"Download speed..."+Str(rate)+" KB/s. Time "+Str(ratetel/1000)+" s.")
EndSelect
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
;
hwnd=OpenWindow(0,100,450,335,160,#PB_Window_SystemMenu,"Downloading "+filenaam$+" from "+server$)
;
If hwnd
If CreateGadgetList(WindowID())
ButtonGadget(1, 250, 128, 72, 20, "Cancel")
ProgressBarGadget(2, 10, 100, 313, 20, 0, 100)
TextGadget(3, 20, 80, 280, 15, "")
TextGadget(4, 20, 65, 280, 15, "")
;
AniWin=CreateWindowEx_(0,"SysAnimate32","",#ACS_AUTOPLAY|#ACS_CENTER|#ACS_TRANSPARENT|#WS_CHILD|#WS_VISIBLE|#WS_CLIPCHILDREN|#WS_CLIPSIBLINGS,25,10,280,50, hwnd,0,GetModuleHandle_(0),0)
;
ConnectionID = OpenNetworkConnection(server$, Port)
;
If ConnectionID
SendNetworkString(ConnectionID, "GET "+URL$+filenaam$+" HTTP/1.0"+eol$)
SendNetworkString(ConnectionID, eol$)
;
SetWindowCallback(@MyWindowCallback())
; -------------- timers ----------------
SetTimer_(hWnd,1,1,0) ; 1 milisecond timer
SetTimer_(hWnd,2,1000,0) ; 1 sec timer
SetTimer_(hWnd,3,500,0) ; 500 msec timer
;
Repeat
EventID=WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 1
header=2
EndSelect
EndIf
Until einde=1
EndIf
EndIf
EndIf
FreeLibrary_(h)
Delay(4000)
;
End
Thanks for the info guys. I tinked around with Freak's code and found out that it does not work with Windows 2000 (all fixes and newest service packs). However, it does work on Win2k3, Windows ME, and havent tried it on anything else yet.
With Win2k, it gives no errors or nothing, just said "0 of 0 bytes complete". Tried this through various people from various ISPs. This code just doesnt work on Win2k.
Berikco: Thanks for that code, I'll take a gander on it and see if its working ok on all OSes I need (win2k, win98, winMe, win2k3, winxp, etc).
With Win2k, it gives no errors or nothing, just said "0 of 0 bytes complete". Tried this through various people from various ISPs. This code just doesnt work on Win2k.
Berikco: Thanks for that code, I'll take a gander on it and see if its working ok on all OSes I need (win2k, win98, winMe, win2k3, winxp, etc).