Program Fryser når det downloader
Hej Jeg har et problem med mit program, programmet henter en fil fra nettet, men mens det downloader fryser programmet det fryser først op igen når downloaden er helt færdig.Hvad er der galt med koden og hvad kan jeg ændre den til:
Håber du kan hjælpe mig
Formen indeholdere: 1 knap (Command1) og 1 tekstbox (Text1)
----Form1----
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, LocalFilename As String)
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
End Function
Public Function GoUpdate()
On Error GoTo Fejlmeddelse
Dim Outfile As String, UrlFile As String, fejl As String
fejl = "Fil sæt"
Outfile = "C:\test.exe"
UrlFile = "Http://test.dk/testfil.exe" ' Filen fylder ca. 7-8 MB (dummy url)
'Download
text1.Text = "Downloader"
fejl = "Download af fil"
DownloadFile UrlFile, Outfile 'Hent fil via funktionen DownloadFile
'Kør fil
text1.Text = "Installere"
fejl = "Update filen findes ikke!"
Shell (Outfile)
'Færdig
text1.Text = "Færdig"
Exit Function
Fejlmeddelse:
MsgBox ("Fejl: " & fejl)
End Function
Private Sub Command1_Click()
GoUpdate
End Sub
----Form1 slut----
//Blueice
