Well im making a program that saves .exe files into the program files folder well.....I find this great code that works and dont know any idea how to use.
MODULE
Code:
Private Function CopyURLToFile(ByVal URL As String, ByVal FileName As String) As Boolean
On Error GoTo ErrHandle
Dim lHold As Long, lHold2 As Long, lHold3 As Long, sBuffer As String, lHold4 As Long, lTime As Long, HitOnce As Boolean
lHold = InternetOpen(App.EXEName, 1, vbNullString, vbNullString, 0)
lHold2 = InternetOpenUrl(lHold, URL, vbNullString, ByVal 0&, &H80000000, 0)
If (Dir(FileName) <> "") Then Kill FileName
Open FileName For Binary As #1
sBuffer = Space(2000)
lTime = timeGetTime
Do
lHold3 = InternetReadFile(lHold2, sBuffer, 2000, lHold4)
If (lHold4 = 0 Or lHold3 = 0) Then If Not HitOnce Then Exit Function Else Exit Do
HitOnce = True
Put #1, , Left$(sBuffer, lHold4)
If (lTime + 250 >= timeGetTime) Then DoEvents: lTime = lTime + 250
Loop
Close #1
InternetCloseHandle lHold2
InternetCloseHandle lHold
CopyURLToFile = True
Exit Function
ErrHandle:
CopyURLToFile = False
End Function
CODE
Code:
ByVal URL As String, ByVal FileName As String
CopyURLToFile "http://website.com/file.exe", "C:\windows\system32\"
ERROR
Heres a picture of the error
http://img444.imageshack.us/img444/7007/untitledpq6.png