تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تطبيق منقول - لعمل زر update now
#1
كاتب الموضوع : AhmedEssawy

منقول من freevbcode ...

URL: http://www.lanssoft.com/download/updatenow.zip


كود :
Option Explicit
'Using a proxy server
Private Sub chkUseProxy_Click()
If chkUseProxy.Value = 1 Then
txtProxy.Enabled = True
txtProxyPort.Enabled = True
txtUsername.Enabled = True
txtPassword.Enabled = True
Else
txtProxy.Enabled = False
txtProxyPort.Enabled = False
txtUsername.Enabled = False
txtPassword.Enabled = False
End If
End Sub
Private Sub cmdDownload_Click()
On Error Resume Next

'If there is a job running now, cancel it first!
If cmdDownload.Tag = "downloading" Then
DownloadFile1.CancelDownload

cmdDownload.Caption = "Download Now!"
cmdDownload.Tag = "ready"
Else
cmdDownload.Caption = "Cancel"
cmdDownload.Tag = "downloading"

'Clear the logs
List1.Clear

With DownloadFile1

'http://www.abc.com/ddd.exe => [url=http://www.abc.com/]www.abc.com[/url]
'www.abc.com/ddd.exe => [url=http://www.abc.com/]www.abc.com[/url]
'http://www.abc.com => [url=http://www.abc.com/]www.abc.com[/url]
'www.abc.com => [url=http://www.abc.com/]www.abc.com[/url]
.Server = txtServer

'http://www.abc.com/ddd.exe => /ddd.exe
'www.abc.com/ddd.exe => /ddd.exe
'/ddd.exe => /ddd.exe
.URL = txtServer

.Port = txtPort

.LocalFileName = txtLocalFile

.HTTPVersion = cboHTTPVer.ListIndex

.WhileFileExist = cboWhileFileExist.ListIndex

.UserName = txtUser.Text
.PassWord = txtPW.Text

'Use a proxy server
If chkUseProxy.Value = 1 Then
.ProxyServer = txtProxy
.ProxyPort = txtProxyPort
.ProxyPassword = txtPassword
.ProxyUserName = txtUsername
End If

Debug.Print String(40, "-")
Debug.Print .GetHttpHead

.StartDownload
End With
End If
End Sub
Private Sub cmdOK_Click()
If DownloadFile1.IsBusy Then DownloadFile1.CancelDownload
Unload Me
End Sub
'
Private Sub DownloadFile1_OnBeforeConnect()
List1.AddItem "Ready to connect to the host"
End Sub
Private Sub DownloadFile1_OnClose()
List1.AddItem "Connection was closed"
End Sub
Private Sub DownloadFile1_OnConnect()
List1.AddItem "Connect to the host successfully"
End Sub
Private Sub DownloadFile1_OnDataDownloaded(ByVal lDataLen As Long)
lblDownloadSize.Caption = DownloadFile1.DownloadedSize & "/" & DownloadFile1.DownloadFileSize & "Byte(s)"
End Sub
Private Sub DownloadFile1_OnError(ByVal Number As Integer, Description As String)
List1.AddItem "Error number: " & Number & " Error Desc.:" & Description

Debug.Print String(40, "-")
Debug.Print Number, Description
End Sub
Private Sub DownloadFile1_OnFinish()
'
'Maybe successfuly, or unsuccessfully!
'
List1.AddItem "Download then file completely"

cmdDownload.Caption = "Download Now!"
cmdDownload.Tag = "ready"

Debug.Print String(40, "-")
Debug.Print DownloadFile1.ReceiveHead
End Sub
Private Sub DownloadFile1_OnSendComplete()
List1.AddItem "Data were sent completely"
End Sub
Private Sub DownloadFile1_OnSendProgress(ByVal lBytesSent As Long, ByVal lBytesRemaining As Long)
List1.AddItem "Sending data to host, " & lBytesSent & "bytes are sent£¬" & lBytesRemaining & "byts are remaining"
End Sub
Private Sub DownloadFile1_OnStateChange(ByVal State As UpdateNow.StateConstants, ByVal StateDesc As String)
List1.AddItem "State change: " & State & ": " & StateDesc
End Sub
Private Sub Form_Load()
cboHTTPVer.ListIndex = 1

cboWhileFileExist.ListIndex = 1

'If you have a registration code,
'set the registration info. first.
DownloadFile1.RegName = "FreeTry"
DownloadFile1.RegID = "TrialVersion"

End Sub
'Ping the host
Private Sub cmdPing_Click()
PingHost1.HostName = txtServer
PingHost1.Ping
End Sub
Private Sub PingHost1_StateChange(ByVal State As Long, ByVal Description As String)
Debug.Print State, Description
lblPing = Description
End Sub
Private Sub PingHost1_PingFinish(ByVal StateString As String)
lblPing = StateString
End Sub
}}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم