最简单的从服务器下载文件的VB代码

第一种方法:后台下载

Private Declare Function URLDownloadToFile Lib "urlmon.dll" 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 Command1_Click()
    URLDownloadToFile 0, "http://192.168.1.101/hbwl.rar", "c:\hbwl.rar", 0, 0
End Sub

 

 

第二种方法:文件另存为

Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long

Private Sub Command1_Click()
    Dim gourl As String
    gourl = StrConv("http://192.168.1.101/hbwl.rar", vbUnicode)
    Call DoFileDownload(gourl)
End Sub

 

你可能感兴趣的:(C++,c,C#,vb)