请问如何用windows api 实现文件的上传与下载(http)?谢谢了!

解决方案 »

  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 Command1_Click()
    URLDownloadToFile 0, "http://office.9zp.com/index.asp", "c:\test.txt", 0, 0
    End Sub上传需要知道服务器允许怎么上传
      

  2.   

    上传建议使用组件,通过web页面
    http://www.ourfly.com/bbs/dispbbs.asp?boardID=4&ID=150利用AspcnUP.dll组件进行文件上传
    提供组件源码(vb写的),有丰富的例程,比较不错
      

  3.   

    下载可以使用inet控件Private Sub Command1_Click()  Dim StrMsg As String
      Dim isbusy As Boolean
      
      Inet1.URL = "ftp://www.xxx.com/"
      Inet1.Protocol = icFTP
      Inet1.UserName = "oxx"
      Inet1.Password = "xxx"
      
      StrMsg = "Dir"
      Inet1.Execute , StrMsg
      
    End SubPrivate Sub Command2_Click()
    On Error GoTo errhandle:
    Dim s1 As String
      
      Inet1.Execute , "Get 2.zip C:\234.zip"
      Do While isbusy
           isbusy = Inet1.StillExecuting
           DoEvents
      Loop
    errhandle:
        MsgBox Err.Description
    End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
    Select Case State
     Case 1
        Text1.Text = "is looking"
    Case 2
        Text1.Text = "success finding "
    Case 3
      Text1.Text = "is connecting"
    Case 4
      Text1.Text = "success connected"
    Case 5
      Text1.Text = "is sending request"
    Case 6
      Text1.Text = "sucess sending"
    Case 7
      Text1.Text = "is receiving"
    Case 8
      Text1.Text = "success receive"
    Case 9
      Text1.Text = "is disconnecting"
    Case 10
      Text1.Text = "success disconnect"
    Case 11
      Text1.Text = "is error"
    Case 12 'icResponseCompleted
      Text1.Text = "success receive data"
      bDowning = False
    End Select
    End Sub
      

  4.   

    用IE来下载
    Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
    Private Sub Command1_Click()
       
       Dim sDownload As String
       
       sDownload = StrConv(Text1.Text, vbUnicode)
       Call DoFileDownload(sDownload)
       
    End SubPrivate Sub Form_Load()
    Text1.Text = "http://www.chat.ru/~softdaily/fo-ag162.zip"
    Form1.Caption = "Audiograbber 1.62 Full"
    Text2.Text = "http://www6.50megs.com/audiograbber/demos/cr-ag161.zip"
    End Sub