CodeItBetter Programming Another VB Programming Blog

How to Download a file from the Internet — without getting a dialog box (in two ways)

Posted on August 24, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'Internet - How to Download a file from the Internet -- without getting a dialog box (in two ways)
'Method 1:

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
 
Private Sub Form_Load()
    Dim llRetVal As Long
    llRetVal = URLDownloadToFile(0, "http://www.yahoo.com", "c:\Temp.htm", 0, 0)
End Sub
 
'Method 2:

Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
 
Public Sub DownloadFile(FileURL As String)
    Dim sDownload As String
 
    sDownload = StrConv(FileURL, vbUnicode)
    Call DoFileDownload(sDownload)
End Sub
Filed under: Internet Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.