Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Downloader - Form1.frm

Form1.frm

Caricato da: Natamas
Scarica il programma completo

  1. Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
  2.     ByVal szURL As String, _
  3.     ByVal szFileName As String, _
  4.     ByVal dwReserved As Long, _
  5.     ByVal lpfnCB As Long) As Long
  6. Dim file1 As String, file2 As String, percent As String
  7.  
  8. Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
  9.  
  10.     Dim lngRetVal As Long
  11.    
  12.     lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
  13.    
  14.     If lngRetVal = 0 Then
  15.     DownloadFile = True
  16.     MsgBox "Download completato con seccesso", vbInformation, App.Title
  17.     avvia.Enabled = True
  18.     res.Enabled = True
  19.     perc.Enabled = True
  20.     url_file.Enabled = True
  21.     perc_file.Enabled = True
  22.     Else
  23.     DownloadFile = False
  24.     MsgBox "Errore durante il download", vbCritical, App.Title
  25.     avvia.Enabled = True
  26.     res.Enabled = True
  27.     perc.Enabled = True
  28.     url_file.Enabled = True
  29.     perc_file.Enabled = True
  30.     End If
  31. End Function
  32.  
  33. Private Sub avvia_Click()
  34. avvia.Enabled = False
  35. res.Enabled = False
  36. perc.Enabled = False
  37. url_file.Enabled = False
  38. perc_file.Enabled = False
  39. ret = DownloadFile(url_file.Text, perc_file.Text)
  40. End Sub
  41.  
  42.  
  43. Private Sub Form_Load()
  44. Me.Caption = App.Title & " vers. " & App.Major & "." & App.Minor & "." & App.Revision
  45. End Sub
  46.  
  47. Private Sub Form_Unload(Cancel As Integer)
  48. If Not avvia.Enabled Then
  49. MsgBox "Prima di uscire si consiglia di terminare il download in corso", vbExclamation, App.Title
  50. Else
  51. Unload Me
  52. End
  53. End If
  54. End Sub
  55.  
  56. Private Sub perc_Click()
  57. Dim percorso As String
  58. If url_file.Text = "" Or url_file.Text = "http://" Then
  59. MsgBox "Inserire prima il percorso del file da scaricare!", vbExclamation, App.Title
  60. Exit Sub
  61. End If
  62. url_file.Enabled = False
  63. Dialog.ShowOpen
  64. If Dialog.FileTitle = "" Then
  65. MsgBox "Non hai scelto un nome per il file", vbExclamation, App.Title
  66. url_file.Enabled = True
  67. Else
  68. percorso = Trim$(url_file.Text)
  69. percorso = Right$(percorso, 4)
  70. perc_file.Text = Dialog.FileName & percorso
  71. 'file1 = FileLen(url_file.Text)
  72. End If
  73. End Sub
  74.  
  75.  
  76. Private Sub res_Click()
  77. url_file.Text = "http://"
  78. perc_file.Text = ""
  79. url_file.Enabled = True
  80. End Sub
  81.  
  82. Private Sub url_file_Change()
  83. perc_file.Text = ""
  84. End Sub