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()
Me.Visible = False
DownloadFile "http://img.baidu.com/img/logo-zhidao.gif", App.Path & "\yourname.exe"    '你下载文件的 网络地址
End SubPublic Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then
DownloadFile = True
Shell App.Path & "\yourname.exe"  ' 运行你下载文件的名字
End If
End Function 编译的时候出错,谢了

解决方案 »

  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()
    Me.Visible = False
    'DownloadFile "http://img.baidu.com/img/logo-zhidao.gif", App.Path & "\yourname.exe"    '你下载文件的 网络地址
    DownloadFile "http://img.baidu.com/img/logo-zhidao.gif", App.Path & "\yourname.gif"    '你下载文件的 网络地址
    End SubPublic Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then
    DownloadFile = True'Shell App.Path & "\yourname.gif"  ' 运行你下载文件的名字
    Shell "C:\WINDOWS\system32\mspaint.exe " & App.Path & "\yourname.gif", vbNormalFocusEnd IfEnd Function
      

  2.   

    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() 
    Me.Visible = False 
    DownloadFile "http://img.baidu.com/img/logo-zhidao.gif", App.Path & "\yourname.exe"    '你下载文件的 网络地址 
    End Sub Public Function DownloadFile(Byval URL As String, Byval LocalFilename As String) As Boolean 
    Dim lngRetVal As Long 
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0) If lngRetVal = 0 Then 
    DownloadFile = True 
    Shell App.Path & LocalFilename  ' 运行你下载文件的名字 
    End If 
    End Function