Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2007, 07:07 PM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Silent Downloader HELP!!!!!

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

 
Old May 17th, 2007, 08:17 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This code seems fishy to me. Downloading exe's to the system32 directory is questionable, i don't care what you are coding.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Book Sample "Downloader" (chap27) J. van der Vegt Pro Visual Basic 2005 0 February 10th, 2006 05:40 PM
Silent SHDocVw.InternetExplorer Jenda Pro VB 6 0 August 31st, 2004 12:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.