[轉貼]VB自動更新-下載

[轉貼]VB自動更新-下載
http://ithelp.ithome.com.tw/question/10054525?tab=opinion

 

Private Declare Function DoFileDownload Lib "shdocvw.dll" _
(ByVal lpszFile As String) As Long
  
Private Sub Command1_Click()
Dim sFileUrl As String
sFileUrl = StrConv("http://123.194.15.246/ezs/ip.php", vbUnicode)
DoFileDownload sFileUrl
End Sub

'=======================================================

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 Command1_Click()
    Dim lReturn As Long
  
    lReturn = URLDownloadToFile(0, "http://www.hosp.ncku.edu.tw/~cww/index.htm", "C:\index.html", 0, 0)
  
    If lReturn = 0 Then
        MsgBox "Download Complete.", vbInformation + vbOKOnly
    End If
End Sub

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *