kanarde
12-27-01, 01:44 AM
Ok, I am trying to make an auto-updater for my program (http://www.nitrousonline.net/nvf). My major problem right now is downloading the updates.
Heres what I have so far:
<START OF CODE>
'-------------------------------------------------------------------------------
Private Sub Command1_Click()
Inet1.URL = "http://www.blah.com/update.exe" 'some address
bar.Value = 0 'Progress Bar
Inet1.Execute , "GET"
End Sub
'-------------------------------------------------------------------------------
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant, DocSize As Long
Select Case State
Case icResponseReceived
If DocSize = 0 Then
If Len(Inet1.GetHeader("Content-Length")) > 0 Then
DocSize = CLng(Inet1.GetHeader("Content-Length"))
Text1.Text = DocSize
bar.Max = DocSize + 1024
End If
End If
Case icResponseCompleted
Dim intFile
intFile = FreeFile()
' Open a file to write to.
Open "c:\windows\desktop\agent.exe" For Binary Access Write As #intFile
' Get the first chunk. NOTE: specify a Byte
' array (icByteArray) to retrieve a binary file.
vtData = Inet1.GetChunk(1024, icByteArray)
bar.Value = bar.Value + 1024
Do While LenB(vtData) > 0
DoEvents
On Error Resume Next
bar.Value = bar.Value + 1024
lblP.Caption = Round((bar.Value / bar.Max) * 100) & "%"
Put #intFile, , vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icByteArray)
Loop
Put #intFile, , vtData
Close #intFile
Case icConnecting
lblStat.Caption = "Connecting..."
Case icConnected
lblStat.Caption = "Connected"
Case icDisconnecting
lblStat.Caption = "Disconnecting..."
Case icDisconnected
lblStat.Caption = "Disconnected"
End Select
End Sub
'-------------------------------------------------------------------------------
<END OF CODE>
The problem is when I use the "put" statement. It adds extra information about the Variant 'vtData'.
I took the download code strait from msdn.
Any help out there?
Heres what I have so far:
<START OF CODE>
'-------------------------------------------------------------------------------
Private Sub Command1_Click()
Inet1.URL = "http://www.blah.com/update.exe" 'some address
bar.Value = 0 'Progress Bar
Inet1.Execute , "GET"
End Sub
'-------------------------------------------------------------------------------
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant, DocSize As Long
Select Case State
Case icResponseReceived
If DocSize = 0 Then
If Len(Inet1.GetHeader("Content-Length")) > 0 Then
DocSize = CLng(Inet1.GetHeader("Content-Length"))
Text1.Text = DocSize
bar.Max = DocSize + 1024
End If
End If
Case icResponseCompleted
Dim intFile
intFile = FreeFile()
' Open a file to write to.
Open "c:\windows\desktop\agent.exe" For Binary Access Write As #intFile
' Get the first chunk. NOTE: specify a Byte
' array (icByteArray) to retrieve a binary file.
vtData = Inet1.GetChunk(1024, icByteArray)
bar.Value = bar.Value + 1024
Do While LenB(vtData) > 0
DoEvents
On Error Resume Next
bar.Value = bar.Value + 1024
lblP.Caption = Round((bar.Value / bar.Max) * 100) & "%"
Put #intFile, , vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icByteArray)
Loop
Put #intFile, , vtData
Close #intFile
Case icConnecting
lblStat.Caption = "Connecting..."
Case icConnected
lblStat.Caption = "Connected"
Case icDisconnecting
lblStat.Caption = "Disconnecting..."
Case icDisconnected
lblStat.Caption = "Disconnected"
End Select
End Sub
'-------------------------------------------------------------------------------
<END OF CODE>
The problem is when I use the "put" statement. It adds extra information about the Variant 'vtData'.
I took the download code strait from msdn.
Any help out there?